Reputation: 1475
Say my current branch is feature-foo
and the working directory is clear (there are no modified files). And I merge another branch feature-baz
on it by: git merge feature-baz
.
What I want is that all the changes from the branch feature-baz
are applied to the files on my current branch but the merge commit should not happen. So, when I do git status
, I should see all the modified files still unstaged.
Is this possible in Git? If yes, how...?
I want to do this because this way, I would be able to do the changes into the code during my code-review process. And then do a manual commit instead of an automated merge commit which is done by Git.
Thanks
Upvotes: 5
Views: 1737
Reputation: 532418
Use the --no-commit
and --no-ff
options with git merge
:
$ git merge --no-commit --no-ff feature-baz
--no-ff
ensures that the merge would create a commit, even if a fast-forward is possible. --no-commit
updates your working directory, but stops before creating the merge commit.
Upvotes: 5
Reputation: 37500
Just use git reset HEAD^
after merging with git merge
.
Important thing is that you merge (this will create merge commit, as you know) and then use git reset HEAD^
- HEAD^
will cause to "revert" to commit before last commit on current branch (!), so right before merge commit.
All changes from that commit will be:
git reset --soft HEAD^
git reset --medium HEAD^
git reset --hard HEAD^
changes will be removed completely, from GIT and from disk, so you do not want that.Side note: --medium
is default option, so you can omit it.
So you want to do:
git merge feature-baz
git reset HEAD^
Upvotes: 0