I have merged an old copy replacing many files that have been replaced by the older version (my last check out..about a week ago). I am wanting to reset to the previous commit (reverse my damage of merging), is there any way to reverse this merge without losing all the changes since the old checkout? Any help will be appreciated, thanks in advance!
If you've already committed the merge, then the only way to really undo it is to check out / update to the commit before the merge was done, and proceed from there. You can discard the merge commit using 'strip' in Mercurial and by using 'Reset <branch> to this commit' in Git. Bear in mind that if you've pushed the merge though, you won't want to do that - you'll just have to leave it as an orphaned stream of development unless you're willing to potentially upset other people.
If, you've made commits after the merge that you want to keep, it becomes trickier. You probably want to cherry-pick the commits across to the new branch point in order to do that, but you should expect some potential conflicts.
Revert/Reversing a merge commit has it's advantages. Hence why it's there in Git itself (I'm not sure about hg here).
That directly references reversing the merge commit, which sourcetree does not handle correctly (with the -m flag).
If you have a branch that had a hypothetical 10,000 commits on it, you then merged (badly) into a branch that 20 other people then began working on immediately afterwards.
To cherry-pick each one of those commits is frustrating—and in this exaggerated example will probably take years if done manually—so the simple solution would be to reverse the merge commit, then attempt it again. With git, this is simply done: `git revert -m`.
However attempting this via SourceTree will fail due to it not applying this flag. Thus resulting in having to throw SourceTree aside and boot up a prompt simply to revert a single commit.
Could this be resolved?
Guys, I found a way, a bit ugly but does the job.
So, do a hard reset to the commit you want to roll back, go to the project folder (Using Finder on Mac or Explorer on Windows) and make a copy of the whole folder. What you have inside this 'Copy' folder is the point you want to be at the end of this process.
Well... go back to source tree and then checkout the Head (the latest commit into your remote), then navigate again to the project folder, be sure you can see hidden folders because you must be able to see a folder called ".git"
Delete everything BUT ".git" from your current project, it means your current project has nothing inside but the folder called ".git", then navigate to your 'Copy' folder and copy everything but ".git" folder and paste the content inside your current project (the one with ".git" folder only)
Done. Go to source tree and commit the changes, your project is exactly where you wanted and all changes removed.
Obs1: Delete the "Copy" folder now to clean your pc from dirty files.
Obs2: This process don't remove your changes from Git, the commits will be there, what you are doing is deleting your changes and committing it.
Thasnk you for the quick response. I found this post later after I had already asked. This does answer a portion of the question. It does fall more into the issue mentioned by Steve. I will investigate with this "cherry picking". I am familiar with its purpose, but have never leveraged this tool. I appreciate the help and believe this will solve my issues. I appreciate the elaborating on the question response (I should have traced through the backlog to better define my question so it is unique).
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events