Home » Tips » Top 7 commands of git you must learn

Summary: In this post, I am going to show the Top 7 commands of git you must learn. These are some basic commands that you must have to learn before continuing with Git. Git is a fast-growing platform to manage code and repository. Git has a lot of features related to managing code and taking backup of files and folders. The best part of git it is very easy to learn. There are many web-based hosting services that using git like Github, Gitlab, and Bitbucket. If you do not know how to download Git you can read (link).

Let’s start,

git clone:- This is a very first command when you are going to clone your repository. You need to add your repository link after this command. For example, as I show below:

git clone https://github.com/gs63875/yii2.git

https://github.com/gs63875/yii2.git is our public repository on git Github you can create yours on any platform like Github, Gitlab, and Bitbucket.
If you do not know how to create a new repository on git you need to read (this article).
After running above command on Terminal, cmd or Gitbash any of these It will ask for your repository username and password. You need to fill this out.

git status:- When you have done with the changes you need to run git status command to check in which file you have done changes. It will show you all those files that updated by you recently.

git add:- This command stage you change for git. It means files get ready to commit run below command:

git add filename  

When you made the changes  in multiple files then you need to run below command:

git add .

git add . add your all files in which you have made changes.

git commit:- After adding the file for commit we need to commit changes for this we need to run for example:

git commit -m "your message"

In this command, we need to a message for our commit. This message is very useful to remember our changs.

git commit -am:- This command is the combination of both git add and git commit command you can run this command like below:

git commit -am "your message"

This command is only working to update or edit. For new add file, you need to run git add and git commit separately.

git pull:- git pull command pull the code from git. If you already working on any repository it pulls only that files that different from your local repository.

That’s all for git 😊. Comment below if you have any question.

 

Meaning of tilde (~) caret (^) wildcard ( * ) in composer.json file
Basic Linux Commands for files and folders

Back to top