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

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

  1. git push origin experiment?

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

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

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

1.1? fetch and track

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

  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代码 git 合并远程分支时候的操作

  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代码 git 合并远程分支时候的操作

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

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

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

2。以前没有clone

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

  1. mkdir newbranch_name?
  2. cd newbranch_name?
  3. git init?
  4. git remote add newbranch_name [email protected]_host_name.com:repository.git?
  5. git add .?
  6. git commit -am "comment"
  7. git push newbranch_name master?

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

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

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

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

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

  1. $git merge master?

4。 提交到远程分支

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

  1. $git push origin rc-0.1?

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

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

  1. $git push origin :rc-0.1?

创建并且跟踪远程分支

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

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

相关文章: