Alright I was inattentive when I was merging some code into a repository(There were major changes in the flow of some code), so I had to revert the merge commit. I went home for the day, and now there are more commits on master, and I can't seem to trigger a merge such that I can get my code into master, as in I have the diffs between the 2 files. I was clumsy and pushed to code to origin already.
Here's the one line graph history of the most recent commits:
How do I get back a proper merge screen so that I can take care of it?
I was thinking I could add another commit to my branch then try to merge it, but that feels hackish.
When code is committed and then reverted on a branch, re-committing the same code will have no effect because of the original revert. For example, say you have one or more commits on branch B
, and you revert them with commit R
:
master
|
* R
|\
| * B
Merging B
into master again will have no effect because git realizes that revert R
happened after all the commits in B
(even if B
is merged again).
There are 2 possible solutions here.
One is to revert the revert (call this commit R'
).
master
|
* R'
|
* R
|\
| * B
The command for this is simple. $ git revert R
The other possible solution is to rebase the entire branch B
so that it comes after the revert R
(call the rebased branch B'
). There are a few different variations of this, but they all depend on rewriting the branch history with new commits that are not present in the history of R
.
master
|
* New merge commit
|\
| * B'
| \
| ...
* R
|\
| * B
| ...
|/
* A
The commands for the rebase are as follows:
$ git checkout B
$ git rebase --no-ff A
Linus has some good commentary on this scenario for more reading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With