Git Tutorial for beginners (Part III)

Let us continue with Git Tutorial for Beginners (Part III). I will recommend you to also go through  Git Tutorial (Part I) and Git Tutorial (Part II)

In the last tutorials, we talked about the basics of Git, Git Installation, Git Config and Git Repository. In this tutorial, we will learn some more Important Git Commands.


Also Read : How to install Git on  Ubuntu/Centos/Amazon Linux/Windows

Git Help

While using Git, you may need help to get more details on any Git command. In that case, you can take help using the following three commands.

        $ git help  < command name>

         $ git < command name > -help

         $ man git <<command name>>

Here are some examples that you can use.

     $ git help config 

     $ git  — help init

      $ man git clone

All the above three commands open the manual help page. In addition, if you don’t want to open the manual page, you can use the below command.

     $ git < command name > -h


     $ git init -h

Git Status

This command shows which files are in which stage. Remember we learned in the previous tutorial that the file may be one of the following stages – Modified, Staged or Committed.

     $ git status

change to your local git repository using the cd command  and check git status

Git add

This command is used for tracking new files for commit.

    $ git add

Let us understand this command. Let us do some changes to file in my_repo and track the file. In the below example I have added a new line ” This is change 1″ in file using the echo command.

Let us now check the git status.

You can see file is now at the modified stage. You can also see the following lines.

” changes not staged for commit:

       (use ” git add < file > … ” to update what will be committed )

       (use ” git checkout — <file> …” to discard changes in working directory)


In the above lines, it is clearly mentioned the file is in the Modified stage( i.e in Working Directory) but not staged for commit yet . If you want to stage it ( i.e want to send it to Staging Area) use ” git add < file > … ” command , else use the command” git checkout — <file> …” to discard the changes.

Now use “git add ” command to track this file to be staged and check git status again.

In the above screenshot ” Changes to be committed ” shows files are staged( In Staging Area) but not committed. You can also use the ” git reset Head <file> …” command to unstage it.

Git Commit

Use the “git commit” command to track the file from the Staging Area to .git Repository. In other word as soon as we run the command, the stage of the file will be changed from Staged to Committed.

    $ git commit -m ” Type the Commit message”

Let us again check the git status.

Now you can see ” nothing to commit, working tree clean” means file is committed now.

I hope you liked this tutorial , Git Tutorial for Beginners Part III, we will continue learning git in our next tutorial for git. If you really enjoyed this, please do share this article with others and also share your feedback/comment in the comment box.

Thanks again!


If you think we helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter

You may also like…

Leave a Reply

Your email address will not be published. Required fields are marked *