Sunday, 14 October 2018

How to revert merged commit in git

Assume i have a branch master and i have done multiple commit to that branch till  1e3a87c,
now create a new branch from master is dev , push some  commit to dev branch till b038437,

now merge dev branch changes into master as below:

# checkout to master branch
# git pull origin dev
# git push origin master

and if you want to merge with tag as below:
#create a tag on dev branch using git tag tag_name  
# checkout to master branch
#git merge tag_name
#git push origin master

Now dev branch merge into master branch

As if we want to revert commit before merge then need to use below:

we need to find out the commit id before merge like 1e3a87c in my case


#git reset 1e3a87c
#git reset --hard
#git push -f origin master



Ref: https://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch/7100005#7100005

No comments:

Post a Comment

links for Data Structure

  1) 𝐁𝐞𝐜𝐨𝐦𝐞 𝐌𝐚𝐬𝐭𝐞𝐫 𝐒𝐧 π‹π’π§π€πžπ 𝐋𝐒𝐬𝐭:  https://lnkd.in/gXQux4zj 2) 𝐀π₯π₯ 𝐭𝐲𝐩𝐞𝐬 𝐨𝐟 π“π«πžπž π“π«πšπ―πžπ«π¬πšπ₯𝐬...