git 回滚到任意版本

命令

git reset --hard xxx

查看提交记录

git log
commit 15bfcbfccb4a6875b1a891e7ec13de74f1c032fa (HEAD -> master, origin/master, origin/HEAD)
Author: Allan 
Date:   Fri Oct 26 17:50:54 2018 +0800

    Create README.md

commit c9a80a3cf366bb7532efe869c1753b37e30af94c
Author: Allan 
Date:   Tue Oct 23 19:17:35 2018 +0800

    finished

commit 5ab542d8f71808afb620b859a976f0b28c853961
Author: Allan 
Date:   Tue Oct 23 18:56:47 2018 +0800

    readme

commit 19895957ae64610711b3b23eeab56141c0a3e78a
Author: Allan 
Date:   Tue Oct 23 18:55:50 2018 +0800

    update .gitignore
:

回滚到某次commit,比如第二次:c9a80a3cf366bb7532efe869c1753b37e30af94c

git reset ---hard c9a80a3cf366bb7532efe869c1753b37e30af94c

此时本地代码是 c9a80a3cf366bb7532efe869c1753b37e30af94c 那次的!

假如要强制提交:
git push -f

你可能感兴趣的:(git 回滚到任意版本)