0

How can I revert multiple commits from a branch created out of master ?

I created a release-1.1 from master. Master includes a jira with following commits. A jira has around 50 commits. Example as below , it has also merge commits in between marked (M)

commits

a364478 b236478 cweyriw(M) ywkherr u498hsd i93wrff(M) eryiwrr werkiwr ... ... .... 
6
  • 1
    Don't look at that branch and it will go away. Or just delete it. Commits are immutable, so you can just ignore them. Commented May 21, 2019 at 13:53
  • Master includes that JIRA with commits Commented May 21, 2019 at 13:59
  • 1
    What is "a jira"? Commented May 21, 2019 at 14:00
  • @isherwood I guess i's a task on a feature branch that contains some 50 revisions for itself. Commented May 21, 2019 at 14:02
  • JIRA is Atlassian's project management board, used with BitBucket. Commented May 21, 2019 at 14:10

1 Answer 1

1

Here is the technique -

Method 1 : Cherry-pick Your Commits alone.
I guess, you do not have to think about others commit. So just pick your commits and go ahead.

Commands to follow:

Assuming commit x & y are committed by you.
Assuming you are in the branch (jira branch)
a. git fetch origin
b. git log --oneline -30 #Note down your commit ID somewhere (x&y)
c. git reset --hard origin/master #BE CAREFUL there should not be any non committed files. Which will destroy this command, if any!
d. git cherry-pick commit-x
e. git cherry-pick commit-y
g. Do the required code changes for reverting
h. git commit.. new changes f. git log --oneline -20 #to confirm


Method 2 : Use revert command.
Assuming commit-a and commit-b you want to revert
a. git revert commit-a
b. git revert commit-b
Please note, this will create new two commits above all.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.