Git merge in the wrong direction

I finished the long merge of the devel branch with master , then I realized that this should be a devel update, that is, the direction should be master โ†’ devel . Is it possible to change the commit destination so that the arrow points from the wizard to the development?

Note: The resulting changes to the files will be the same for d->m and m->d . This is just the final destination (and arrow in history), which is wrong.

now: enter image description here preferably: enter image description here

 blue: master red: devel 

* Changes not yet committed or committed.

recapitulation

  • I resolved all conflicts in the master merge devel-> .
  • I did not commit or push changes.
  • Changes made on top of the wizard.
  • I need to apply resolved conflicts in the direction of master-> devel .
+7
source share
4 answers

Returning a merge on a branch is as simple as determining which commit was the previous one.

First, check on the branch you want to change. This rule is git -golden: you can only change the branch you are in.

 git checkout master 

Then, find out that the previous master fixed this, and return the master to the previous state

 git reset --hard <previous-commit-id> 

Finally, do the right merge

 git checkout devel git merge master 

What you could do if you want to be lazy is the inverted state of the branches.

You still need to find master previous commit it.

Then:

 git checkout devel git reset --hard master git checkout master git reset --hard <previous-commit-id> 

That should do the trick.

+6
source

I would force the dev branch to take the current master head, and then reset master HEAD back to one latch. For instance:

 git checkout master git branch -f devel HEAD # force "devel" to equal current "master" git branch -u origin/devel devel # set "devel" upstream tracking. git reset --hard HEAD~1 # set "master" back one commit. 

And if you like what you see ...

 git checkout devel git push 
0
source

In order not to lose any work, given your exact situation, I forced the develop branch to take the current main HEAD, and then reset master HEAD back to one latch. For instance:

 git checkout master git branch -f devel HEAD # force "devel" to equal current "master" git branch -u origin/devel devel # set "devel" upstream tracking. git reset --hard HEAD~1 # set "master" back one commit. 

And if you like what you see ...

 git checkout devel git push 
0
source

It is actually a bit simpler than blue112. First lock the wizard locally.

 git checout master git commit 

This will create a common commit for master and devel. Then switch to devel and combine it with master as well. This will lead to an accelerated merger, since there are no conflicts left.

 git checkout devel git merge master 

It must be saved in order to push devel now.

 git push devel origin/devel 

Now revert the master to its previous commit so that it remains the same as it was before the merge:

 git checkout master git reset --hard <previous-commit-id> 

The workspace must be clean and safe.

0
source

All Articles