github - Git如何删除版本库中的一个提交?
PHP中文网
PHP中文网 2017-04-21 10:57:13
0
3
758

如果不小心在测试代码中写上了用户名和密码,而且已经commit到git中,那么我要怎么把这次commit删除掉,让它在历史中不会出现?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
左手右手慢动作
  1. git reset --hard HEAD~1
  2. git push --force
黄舟

:git checkout -- file can discard the modifications in the workspace;
:git reset HEAD file can undo the modifications in the temporary storage area and return it to the workspace state;
:git reset --hard HEAD^ to return to " The status when adding distributed” version;

迷茫

git reset --hard HEAD~1

git revert HEAD

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template