0

I am Using GitHub for version Control

Unfortunately, I merged the branch with master using the below code

git checkout master
git merge updating-users

Now, I just want to know , How to de-merge the branch(updating-users) from master?

Josh Leitzel
  • 15,089
  • 13
  • 59
  • 76

2 Answers2

1

From within master, do a git reset --hard #commit_id to the most recent good commit on master. (You can get the commit id by going git log.) The updating-users branch will be unaffected.

If you've already pushed the merge to GitHub, you'll have to push again and pass --force since you've overwritten the history.

Josh Leitzel
  • 15,089
  • 13
  • 59
  • 76
0

How to revert Git repository to a previous commit?

http://www.kernel.org/pub/software/scm/git/docs/git-revert.html:

Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them. This requires your working tree to be clean (no modifications from the HEAD commit). Note: git revert is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one). If you want to throw away all uncommitted changes in your working directory, you should see git-reset(1), particularly the --hard option. If you want to extract specific files as they were in another commit, you should see git-checkout(1), specifically the git checkout -- syntax. Take care with these alternatives as both will discard uncommitted changes in your working directory.

If you want to undo only one commit on the master:

git revert #commit_id_to_undo

The git revert is similar to the functionality of patch -R file.patch.

Community
  • 1
  • 1
0x90
  • 39,472
  • 36
  • 165
  • 245