Archive
Useful Git Commands
As our project migrated from SVN to GIT repository, I thought of writing a post of the usual git commands which I find helpful where I could easily refer to.
**Set up Local Repository
#clone a repository into a new directory locally
git clone <SSH key>
#checkout a branch or path to the working tree
git checkout <branch name>
**Working with Branches
#display all the available branches in your local, highlighting the active branch
git branch
#download all/new branches
git fetch
#switch working branch
git checkout <branch name>
#create new branch locally
git checkout -b <branch name>
#push newly created branch to remote
git push -u origin <branch name>
**Committing Local Changes to remote
#show staged files for commit, not staged files for commit and untracked files.
git status
#include what will be committed, stage the changes
git add <file>
#discard changes
git checkout — <file>
#to add message for commit
git commit -m “message here”
#take latest commits on the mentioned branch
git pull origin <branch name>
#push local changes to the remote
git push origin <branch name>
Recent Comments