M
M
Mikhail Abroskin2018-07-10 10:38:13
git
Mikhail Abroskin, 2018-07-10 10:38:13

How to return a branch that was accidentally merged with the master, and then rolled back?

Hello colleagues!
Help solve the problem.
It meant several branches for development, for a preview they collected all the branches into one and pushed them into the gitlab, and as it turned out, this branch for the assembly was created incorrectly, and all the changes flew into the master (((since a lot of people are working on the project, everything had to be done quickly revert in gitlab, respectively, after this revert, all those branches that were merged can no longer be merged, because they were already merged into the master and reversed ... actually the question is how to return the relevance of these branches with all the changes so that you can merge them to the master again, when will it be needed?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Abroskin, 2018-07-10
@miker059

Yes, the master is rolled back, the problem is being solved, but the fact is that a lot of people work and many have already created branches from the reversed master, and accordingly, if the master is hard rolled back, then when those branches that were created from the reversed master start merging, then only God knows ..
In short, the problem was solved in a more peaceful way, everything turns out to be much simpler ...
Locally, all the affected branches were merged one by one with the new master, which wiped out all the edits in them, after which they pushed them into the gitlab . In the gitlab itself, we found commits with a merge to the master, the last of which were with all the changes in the branch and cherry-picked these commits back each to their own branch ... in fact, after which everything returned to its place ...

Y
youngmysteriouslight, 2018-07-10
@youngmysteriouslight

There is a rough way:
0) git-checkout to the desired branch.
1) git-reset to the commit that was the head before the merge.
Due to the peculiarities of the git, it is generally impossible to find out from the history, so you have to guess, focusing on the names of the commits, or on the git-revlog, if available.
2) git push -f <repository name> <changed branch name>
In this case, you need to make sure that none of your colleagues will push to these branches.

O
Oleg, 2018-07-10
@Austin_Powers

Perhaps git reflog
will help you. Stores all actions on a branch, including merges and rebases.
1) Go to master
2) Rollback master to the right moment (probably before all your branches were merged there)
3) Force push.
But be careful, still a master. )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question