Showing posts with label revert merged tag. Show all posts
Showing posts with label revert merged tag. Show all posts

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

links for Data Structure

  1) 𝐁𝐞𝐜𝐨𝐦𝐞 𝐌𝐚𝐬𝐭𝐞𝐫 𝐢𝐧 𝐋𝐢𝐧𝐤𝐞𝐝 𝐋𝐢𝐬𝐭:  https://lnkd.in/gXQux4zj 2) 𝐀𝐥𝐥 𝐭𝐲𝐩𝐞𝐬 𝐨𝐟 𝐓𝐫𝐞𝐞 𝐓𝐫𝐚𝐯𝐞𝐫𝐬𝐚𝐥𝐬...