Git Commands Quick Notes

Fetch

This command is to make sure your local repository has the same knowledge of the remote-tracking branches as the server.

git fetch <remote name>

Check out a Remote Branch

If a new remote branch doesn't have a local branch mapped to it, you need to check out the remote branch locally to work on it. The complete command is,

git checkout -b <local branch name> <remote name>/<remote branch name>

If you want to fetch  all the branches on the server

git branch -v -a

References:

http://stackoverflow.com/questions/1783405/checkout-remote-git-branch

Push

Push changes to remote. (If the remote doesn't have the branch, the branch will be created)

git push <remote name> <branch name>

 

Renaming a branch (a complete version of push command)

This can delete a  remote branch by providing empty local branch name.

git push <remote name> <local branch name>:<remote branch name>

References:

https://help.github.com/articles/pushing-to-a-remote/

http://stackoverflow.com/questions/2765421/push-a-new-local-branch-to-a-remote-git-repository-and-track-it-too

 

posted @ 2016-07-01 09:41  quanben  阅读(146)  评论(0编辑  收藏  举报