Andreas Grech
Andreas Grech

Reputation: 107950

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 commits, 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.

Upvotes: 1

Views: 198

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993095

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.

Upvotes: 4

Related Questions