Git is an open-source version control system used heavily in software development. When working with a large team, version control of the project becomes necessary, bringing git into the picture.
It may get a bit difficult for a new developer to understand git initially. There are many commands in git that you can use. Let’s see some basic git commands that every developer should know.
git clone
The git clone command creates a copy of your remote repository into your computer. The copied repository on your system is linked with the remote repository so that you can regularly update your changes and access the changes done by other developers in the remote repository.
Syntax
git clone <link to your repository>

Also read: How to remove a remote Git repository?
git checkout
You can have multiple branches in your git project, and depending on the feature you are working on, you may have to switch between branches. In such a scenario, you use the git checkout command.
Syntax
git checkout <branch name>
You can use the ‘-b’ option to create and switch to the branch you just created.
Syntax
git checkout -b <new branch name>

git status
The git status commands show you the current status of your repository and current branch. It tells you about the tracked files, the staged files, changes are made, any new or deleted files. It tracks your repository and current branch.
Syntax
git status
The example here shows the output of the git status command, where initially there was no change and the repository was up to date. Later, after some changes, the git status command showed changes in the file.

Also read: How to rename a branch in Git? Local and Remote
git add
The git add command adds your new, modified file into the staging area. It tells your Git to track the new or modified file. If you don’t use this command, the git will not track any new file you create or the modified file, and your changes will not add to the commit.
Syntax
git add <file name>
You can use the ‘-A’ option to add all the files to the staging area.
Syntax
git add -A

git commit
You use the git commit command when you want to save the changes. Commit is like a checkpoint where you can roll back later on if you’re going to undo the changes. This command saves the changes in the local repository in your system.
Commit allow you to add a message with your commit using the ‘-m’ option.
Syntax
git commit -m "Type your message here"

Also read: What is DevSecOps? DevOps vs DevSecOps
git push
When you want to send your changes to the remote repository, you use the git push command. This command pushes only your commits to the remote repository.
Syntax
git push <remote> <branch name>

git pull
The git pull command fetches all the latest updates from the remote repository into your local repository.
The git pull command can give you some conflicts which you will have to resolve manually.
Syntax
git pull

Also read: How to remove untracked files in Git?