Search code examples
gitgithubgit-diffgit-tag

How can I update my current master branch with an old git tag after comparing diff between them?


I want to check the diff between current master branch and an old git tag (lets say, tag1).

After checking the differences, I want to discard the changes and merge tag1 into my master branch because tag1 is currently running in production and I want my master to be updated with it.

How can I do these tasks?


Solution

  • You could use git revert, assuming tag1 is an older commit on the master branch:

    git revert tag1..master
    

    Or you can use git reset (with the --soft option):

    git switch master
    git branch tmp master
    git reset --hard tag1
    git reset --soft tmp
    git add .
    git commit -m "commit tag1 content to master"