开发者

Git: Converging branches to a single commit object

Say I currently have the following in git:

master
  O
  |
  o  <-- commit objects on master branch
  |   
  o -- O  <-- new branch: featureX
       |
       o  <-- commit objects on the featureX
       |
       o

So I started with the master branch and after two comm开发者_高级运维its, I branched to featureX.

Now, after 2 commits on featureX, I want to converge it with master and continue work on master from the last commit on featureX.

This means that I don't want to merge the files between master and featureX but transferring all the commits done on featureX to master and continue working on master from the last commit that was done on featureX.

Basically, something like this:

master
  O
  |
  o  <-- commit objects on master branch
  |   
  o -- O  <-- new branch: featureX
       |
       o  <-- commit objects on the featureX
       |
  o -- o  <-- move everything back to master
  |
  o  <--continue working on master

What are the steps I need to follow in order to this?

Note that I do not want to merge any files together...just overwrite the stuff on master. You can also assume that no work has been done on master while working on featureX.


If no other work has been done on master since branching for featureX:

git checkout master
git merge featureX

This will be a "fast-forward" merge that should do what you want. After the above, you can:

git branch -d featureX

to delete the old branch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜