Reputation: 1934
In git, how do i revert all the changes of one branch from another branch.
I have previously branched from the master
branch to a branch called feature/new-feature
While working on my feature other people also worked from the master
branch and many were merged back into master
(including mine).
Suppose i want to remove all the changed i made on feature/my-feature
from the master branch. What git command would i need to use to do this?
Upvotes: 3
Views: 6680
Reputation: 2155
I assume things were merged, and not rebased.
run a git log --all --decorate --oneline --graph
to get a pretty graph of your history. Find the commit hash of the merge where your branch was merged into master.
You'll want to do a git revert
. However, as this is a merge, you'll need to choose one of the two parent commits for this commit. You can tag on a -m 1
to indicate that the parent commit to choose is the commit from the branch that was merged into (master). Run git revert -m 1 <merge commit hash>
, and resolve any conflicts.
This will appear as a single commit, and can be re-revert
ed/reset
at a later point if done incorrectly.
Upvotes: 4