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

本文详细介绍了如何使用Git进行远程分支的各种操作,包括创建、删除、合并远程分支等,并提供了具体的命令实例。对于初次接触Git远程分支管理和协作的开发者来说非常实用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

update(june 12 2012):
github创建远程分支有点不一样

Js代码 收藏代码

  1. git push origin experiment?

http://learn.github.com/p/branching.html
update:
创建远程分支:
两种情况
1。 以前clone过

Ruby代码 收藏代码

  1. git push origin head:newbranch_name
  2. git push origin head:feature/newbranch_name?

1.1? fetch and track

Ruby代码 收藏代码

  1. git checkout -b newbranch_name --track origin/feature/newbranch_name?

if you got

引用

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?

Ruby代码 收藏代码

  1. #I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try:
  2. git remote show origin?
  3. #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:
  4. git remote update?
  5. git fetch?
  6. #Now it should work:
  7. git checkout -b local-name origin/remote-name?

1.2 delete remote branch

Ruby代码 收藏代码

  1. git push origin :refs/heads/feature/newbranch_name?

Ruby代码 收藏代码

  1. #删除远程分支,其它开发者要git branch -d -r 分支
  2. git push origin :newbranch_name

2。以前没有clone

Ruby代码 收藏代码

  1. mkdir newbranch_name?
  2. cd newbranch_name?
  3. git init?
  4. git remote add newbranch_name git@git_host_name.com:repository.git?
  5. git add .?
  6. git commit -am "comment"
  7. git push newbranch_name master?

在项目过程中,遇到了要在git上合并两个远程的分支,过程记录如下:
1。 查看远程有什么分支
git 合并远程分支时候的操作 - 我爱我的老婆 - 游龙
2。在本地创建一个要合并的原创分支

Ruby代码 收藏代码

  1. $git checkout -b rc-0.1 origin/rc-0.1?

3。 Merge分支的稳定的master分支

Ruby代码 收藏代码

  1. $git merge master?

4。 提交到远程分支

Ruby代码 收藏代码

  1. $git push origin rc-0.1?

其中,冲突解决另外考虑,前提是已经clone或者fetch了主要的分支
update:
删除远程分支:

Ruby代码 收藏代码

  1. $git push origin :rc-0.1?

创建并且跟踪远程分支

Ruby代码 收藏代码

  1. $git checkout? [-b rc-0.1]? --track origin/rc-0.1?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值