Git: common and useful commands

22 Mar 2012 at 00:00:00 - 0 comment(s)

I use git and literally love it but I have one problem with it, I often forget how to do things meaning I always have to go look for it either on the internet or in the manual. Therefore I have decided to write this post to regroup all the commands I use/need when using git.

To add a remote repository

git remote add  user@host:

To delete remote branch

git push origin --delete 

To push branch to remote

git push  

To re-integrate a branch into master, you rebase your local branch with master and then push it to remote master. Like this:

git checkout 
git rebase master
git push origin master

To create a branch and push it to remote

git checkout -b 
git push origin 

To tag a release

git add --all
git commit -m "blabla"
git tag -a  -m "Comment"
git push --tags

To set global config such as name and email

git config --global user.name "Your Name"
git config --global user.email your@email.com

To move a svn repo to git

git svn clone  -A authors --stdlayout 
git remote add origin 
git push origin master:master

To checkout a tag

git checkout tags/

To set user email and name (remove --global to set it just for current repo)

git config --global user.email user@domain.com
git config --global user.name yourname

To reintegrate changes from a branch into master, from your local branch

git fetch
git rebase origin/master
git push origin your_branch:refs/heads/master

To migrate svn repository to git

git svn clone [SVN repo URL] --no-metadata --stdlayout repo_name
git remote add new_repo url_git_repo
git push new_repo refs/remotes/*:refs/heads/*

0 comments

Notify me of follow up comments