Skip to content

Instantly share code, notes, and snippets.

@vanpariyar
Last active November 15, 2022 09:54
Show Gist options
  • Save vanpariyar/48b6cc5b470b5bc21d16ff2298dd1373 to your computer and use it in GitHub Desktop.
Save vanpariyar/48b6cc5b470b5bc21d16ff2298dd1373 to your computer and use it in GitHub Desktop.
Backup Plan - Git Rollback to specific version for the large project

This isn't a direct answer to the question but this page comes back when searching for ways to revert a branch's code to a tag release.

Another way is to create a diff between the current state of the branch and the tag you want to revert to and then apply that to the branch. This keeps the version history correct and shows the changes going in then coming back out again.

Assuming your branch is called master and the tag you want to go back to is called 1.1.1

https://stackoverflow.com/questions/6872223/how-do-i-revert-master-branch-to-a-tag-in-git

git checkout 1.1.1
git diff master > ~/diff.patch
git checkout master
cat ~/diff.patch | git apply
git commit -am 'Rolled back to version 1.1.1'
git push origin master

See also https://stackoverflow.com/questions/37347350/git-patches-cause-error-unrecognized-input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment