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

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,github

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

If you want to fetch  all the branches on the serverapp

git branch -v -a

References:fetch

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

Push

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

git push <remote name> <branch name>

 

Renaming a branch (a complete version of push command)blog

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

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

References:get

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

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

相關文章
相關標籤/搜索