first create the branch locally and then push it to the remote repo
$git checkout -b new_branch_name
$git push origin new_branch_name
Finally, add the following to ".git/config":
[branch "new_branch_name"]
remote = origin
merge = refs/heads/new_branch_name
list branches
$git branch -a ... shows all local and remote branches $git branch -r ... shows only remote branches or use the following to displays plenty of information about the remote in general and how it relates to your own repository: $git remote show origin
merge back into master branch
$git checkout master $git merge new_branch_name ... resolve conflicts (TODO: add more here)
finally removed the unused branch
Locally: $git branch -d new_branch_name On remote server: $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/new_branch_name remotes/origin/master $ git push origin :new_branch_name To ssh://host/home/git/... - [deleted] new_branch_name $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master Wooo ! many thanks to http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html
other example with a submodule
cd src/forum
git status
# Not currently on any branch.
git checkout master
# Previous HEAD position was 0816d91... Updated locales
# Switched to branch 'master'
git pull
git checkout -b assiweb
git push origin assiweb
Advertisement
In your final example, will just this:
git push origin
push all local branches to origin (and hence also your new ‘assiweb’ branch)?
Comment by gcbenison — 25/01/2012 @ 07:07
Unfortunately I mostly work on “master” branch most times, and only occasionally use a secondary branch (blame on me !)
For this reason I’m still unfamiliar with branch specific git commands and options.
My “survival strategy” when using a branch is to have it behave like the default “master” branch as much as possible (i.e. “remote tracking”)
Comment by morlandi — 02/02/2012 @ 17:18
@gcbenison: I experienced that:
git push
does actually push all local “tracking” brances
Comment by morlandi — 16/02/2012 @ 16:44