Basic Commands of Git for Beginners

In this blog you will get to know all the basic commands for git which are commonly used by all the git users . A simple description of command is also given with the commands . Still if you have any question regarding any particular command you can let me know in the comment section .

Global Configuration in Git

Command for setting global Name and Email in your Local machine for git

Adding Aliases in Git

Git gives a functionality to set your own Aliases for commands. For this you use “alias” Keyword followed by Period symbol (.) and then the short command you want to work with .

To use the command now ,you will time as follows :

Creating Git Repository on Local Machine

This will create a Folder/Directory in your local machine

This command will move into the Folder/Directory you have just created

This command will initialize the current folder and create a “.git” folder in the directory . This “.git” folder will be hidden by default.

Check Git Status

Check the status of files. Weather the files are modified, if modified are they added to staging area or are the files untracked which means the new files are created .

Adding File in Git

or to add all the files

Git Commit Command

Making commit to the changes we just have added . Now when we use add command we ask git to make the files ready . Not when we are done with adding we need to finalize the changes for that we use commit command

Git Push Command

Now we have finalized the changes using commit command, we have to send the data to our remote repository “GitHub” or “Bitbucket”, for this we use commit command Send updates to the remote repository.

Creating a new  Branch

Delete a Branch In Git

Check all Branches in Git

This show the all the branches you have on your local machine and also the current branch you are working in with a Star Symbol (*).

Changing or Switching the  Branch

Clone a Repository

Update local repository

Or if you want to pull the data from remote repository for any branch say “master” branch then.

Show changed files in Git

Checks changes between two commits

Check History of commits

Check changes in a specific commit

Check changes in a file commit

Moving back to the previous commit totally discard the current commit

Note : Be careful with this process/command because there is no way to recover once the data is gone.


Leave a Reply

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