Revert to a specific tag in Git (Linux)

1. Add Tag to commit

git tag <your_tag> <short commit hash>

Or you can use Github release to add a version tag

2. Revert specific tag

git checkout -b <version>
git diff-index <branch> --binary > ~/diff.patch
git checkout <branch>
cat ~/diff.patch | git apply
git commit -am 'Rollback to <tag>'
git push origin <branch>

When your commit include any binary file

git diff-index <branch> --binary  > ~/diff.patch

If not

git diff <branch>  > ~/diff.patch

If you don’t use Tag

#Get short commit hash
git log --oneline
#------------------------
#If you see error like this
error: a cherry-pick or revert is already in progress
#Use this command to fix it
git cherry-pick --abort
#--------------------------
#If you want to revert merge commit
git show <commit>
#-----your commit-----
> commit 5aff2f517294b31e1c2042ce08e6ae2fe27af3a6 (HEAD -> ?> > origin/master, origin/HEAD, develop)
> Merge: e607003 725d87e
#---------------------
# 1: e607003 , 2: 725d87e, 1 is prev merge commit
git revert 5aff2f5 -m <1 or 2>
#---------------------
#If not merge commit
git revert <short_hash>
#Revert multiple commits
git revert --no-commit A
git revert --no-commit B
git revert --no-commit C
git commit -m "Revert multiple commits"