Branch - grnet/e-science GitHub Wiki
Assumes Git 1.7.x (minor changes would be needed for 1.8+)
How to:
- branch locally
- push new branch to remote
- setup tracking for easier push / pull
- merge from new branch
- (optional) remove remote branch
- (optional) cleanup tracking for removed branches
- (optional) delete local branch
git checkout -b <new_branch> <source>
eg. git checkout -b ES259 develop
While on new branch (check with git status).
git push <remote> <new_local>[:<new_remote_branch_name>]
eg git push origin ES259:ES259
Can get info about remotes with git remote -v
While on new branch (check with git status).
If on Git 1.x
git branch --set-upstream <new_branch> <remote>/<new_branch>
eg git branch --set-upstream ES259 origin/ES259
If on Git 2.x
git branch -u <remote>/<new_branch>
eg git branch -u origin/ES259
Now you can push / pull to the correct tracked branch without having to explicitly specify it.
Can get info about tracking relations with git branch -vv
While on branch you want to merge into from new branch.
git fetch <remote>
git merge <remote>/<new_branch>
Can also git merge --no-ff <new_branch>
if you prefer to retain all commit history.
git push <remote> --delete <new_branch>
eg. git push origin --delete ES259
alternative git push origin :ES259
git remote prune <remote>
eg. git remote prune origin
git branch -d <new_branch>
eg. git branch -d ES259