[color=red]update(june 12 2012):[/color]
github创建远程分支有点不一样
[url]http://learn.github.com/p/branching.html[/url]
[color=red]update:[/color]
创建远程分支:
两种情况
1。 以前clone过
1.1 fetch and track
if you [url=http://stackoverflow.com/questions/945654/git-checkout-on-a-remote-branch-does-not-work]got[/url]
[quote]
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'feature/newbranch_name' which can not be resolved as commit?
[/quote]
1.2 delete remote branch
2。以前没有clone
在项目过程中,遇到了要在git上合并两个远程的分支,过程记录如下:
1。 查看远程有什么分支
[img]http://dl.iteye.com/upload/attachment/251607/8f433f27-7de0-3b83-9d6f-80c04f134eb5.png[/img]
2。在本地创建一个要合并的原创分支
3。 Merge分支的稳定的master分支
4。 提交到远程分支
其中,冲突解决另外考虑,前提是已经clone或者fetch了主要的分支
update:
删除远程分支:
创建并且跟踪远程分支
github创建远程分支有点不一样
git push origin experiment
[url]http://learn.github.com/p/branching.html[/url]
[color=red]update:[/color]
创建远程分支:
两种情况
1。 以前clone过
git push origin head:newbranch_name
git push origin head:feature/newbranch_name
1.1 fetch and track
git checkout -b newbranch_name --track origin/feature/newbranch_name
if you [url=http://stackoverflow.com/questions/945654/git-checkout-on-a-remote-branch-does-not-work]got[/url]
[quote]
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'feature/newbranch_name' which can not be resolved as commit?
[/quote]
#I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try:
git remote show origin
#If the remote branch you want to checkout is under "New remote branches" and not #"Tracked remote branches" then you need to fetch them first:
git remote update
git fetch
#Now it should work:
git checkout -b local-name origin/remote-name
1.2 delete remote branch
git push origin :refs/heads/feature/newbranch_name
#删除远程分支,其它开发者要git branch -d -r 分支
git push origin :newbranch_name
2。以前没有clone
mkdir newbranch_name
cd newbranch_name
git init
git remote add newbranch_name git@git_host_name.com:repository.git
git add .
git commit -am "comment"
git push newbranch_name master
在项目过程中,遇到了要在git上合并两个远程的分支,过程记录如下:
1。 查看远程有什么分支
[img]http://dl.iteye.com/upload/attachment/251607/8f433f27-7de0-3b83-9d6f-80c04f134eb5.png[/img]
2。在本地创建一个要合并的原创分支
$git checkout -b rc-0.1 origin/rc-0.1
3。 Merge分支的稳定的master分支
$git merge master
4。 提交到远程分支
$git push origin rc-0.1
其中,冲突解决另外考虑,前提是已经clone或者fetch了主要的分支
update:
删除远程分支:
$git push origin :rc-0.1
创建并且跟踪远程分支
$git checkout [-b rc-0.1] --track origin/rc-0.1