git 合并远程分支时候的操作

[color=red]update(june 12 2012):[/color]
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值