Home git How to cancel MERGE without losing code?

How to cancel MERGE without losing code?




Development led in Master. Then he made validation in the Validation and GUI branch in the GUI branch. It was necessary to lay out on Githab with different branches. And I Murded in Master and Validation and GUI and only after that sent to Githab. Can I fix it?

It is important for me that it would be on the guithab that they were displayed as different branches. Therefore, if there is a way on the site itself to divide visually, while on the computer leaving merges, then this method will also suit me.

code in these branches suits me, and there were no conflicts during the merger. I want to divide, only because people who will study the project on Githab must clearly understand where the Master branch ended. Those. Only a small part of the project must be in the master. And I got it that the whole project in master.

Answer 1, Authority 100%

First, losing the code in the GIT is not so easy. If that, you always have Git Reflog to Restore lost commote . And you can always make a backup of the current branch using Git Branch Backup (arbitrary name).

Next, you need to roll back the MASTER branch to Commit before merging: Git Reset --hard Commit-Name . Read more: How to return (roll back) to an earlier commit?

just so run the branch will not work, because On Githabe now there are commits, which in your branch is not, so it will not be automatic Fast-Forward Merge. It will help GIT PUSH -F . This command replaces the contents of the remote branch.

It remains to run the remaining branches. To do not specify the local and remote branch every time, you may once assign a remote UpStream-branch remotely removed:

Git Push -u Origin Master
Git Push -u Origin Validation
Git Push -u Origin GUI

You can run all branches at once (in general everything in Refs / Heads / ):

git push -u --all origin
Branch Master Set Up to Track Remote Branch Master From Origin.
Branch Validation Set Up to Track Remote Branch Validation From Origin.
Branch GUI Set Up to Track Remote Branch Gui From Origin.

Answer 2, Authority 7%

You can return to the previous commit using Git Reset Mixed & LT; Committed & GT;

Answer 3, Authority 7%

There is an option without Force Push (not always it is possible)

  1. We cancel in the MERGE MERGE Commit command REVERT , send changes to the server
  2. continue to work in the branch
  3. Before MASTER MASTER TRANSFER, cancel the REVERT command. The step is mandatory, otherwise some of the changes will not get sick, as Git will consider that they were made, and then canceled and they do not need to murry


Curve translation source

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions