Git Commands

We are using various version controls and GIT is one of the good version control system. Now it is our day to day work to use git and there are a lot of commands of git which we need daily. I thought it would be better to document these here

1. Get the Repo from Git Remote to your local for the first time use
$ git clone https://type- yout-git-remote-repo-path
in case you want to clone a specific BRANCH then use
$ git clone https://type- yout-git-remote-repo-path -b

2. Now if you have made some changes and you want to check what are the files which are changed for the purpose you can use “STATUS”
$ git status

3. Once you have done some changes to the repo code and you want to push these changes to Remote repo then you have to do two steps “Commit” and “Push”
-If you want to commit all the changed files the use this command
$ git commit -m "Enter your comment here "
-If you want to push specific files or folder the use
$ git commit -m "Enter your comment here " folder-name/ folder-name/filename filename

After commit now push your code using
$ git push
if you want to PUSH specific branch use
$ git push origin branch-name

4. Ideally before committing your changes you should first “Pull” the repo code to make sure that you do not try to overwrite other persons code. Because if someone else has committed code before your commit there is possibility of conflicts. For that use “PULL”
$ git pull
if you want to pull specific branch use
$ git pull origin branch-name

5. If you want to switch between the Repo branches then use “CHECKOUT” command
$ git checkout origin branch-name

6. If you want to delete a FOLDER or FILE from your REMOTE repo, permanently then use following command
$ git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FOLDER-NAME " HEAD
Once process is complete run push command
$ git push origin master


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: