DEV Community

Mathu varshtih
Mathu varshtih

Posted on

Introduction to Git : Beginner level

What is git?

Git is the distributed version control system that tracks change in computer files , primarly used for coordinating work among the deveopers writing software source code.

Types of version control:

  1. Local version control system.
  2. Centralized version control systrem.
  3. Distributed version control syatem.

Basic Git Commands:

  • git init – Initialise the working directory.
  • git add <filename> - Adds the specified file to the staging area.
  • git commit -m “write the message msg” - commit command helps to commit in history.
  • git push origin main - push your file to the repository (github/gitlabs) – {assume when the remote is orgin and main}.
  • git status – to find the status of the directory.
  • git log – It is used to see the history of commit.

Some additional useful commands:

  • git diff – shows the older and new change.
  • git rm --cached <file name> - remove the the file from git.
  • git switch -c <branchname> - to create a branch.
  • git switch <main/branchname> – to swtich between branches and main.
  • git merge <branchname> -to merge the branch.
  • git stash - Temporarily saves uncommitted changes.
  • git fork - personal copy of someone else's repository.

Top comments (0)