stacknoob
stacknoob

Reputation: 49

How to make a previous commit the head of the master branch while ignoring everything from the most recent merge into master?

Current scenario:

The catch: Developer 2's work would break production if deployed.

So in BitBucket, it looks kinda like this:

31 jan merge dev2 branch into master
31 Jan commit_hash_for_dev2
25 jan commit hash_for_dev2
21 jan commit hash_for_dev1 (currently what is in production)
15 jan commit hash_for_dev2
12 jan commit hash_for_dev2

Do I do:

git checkout hash_for_dev1 . (where the dot makes it the head)
git commit -m "reverting dev2 changes)
git push origin master
open a pull request

How do I bring the master branch head to dev1 latest commit and ignore everything dev2 merged ?

Upvotes: 1

Views: 53

Answers (1)

VonC
VonC

Reputation: 1328202

The idea would be to use git revert, in order to revert a range of commit

git revert -m 1 OLDER_COMMIT^..NEWER_COMMIT

That would create a new commit, with the negative image of dev2 most recent commits.
You can push that and make a pull request.

Upvotes: 1

Related Questions