search

Home  >  Q&A  >  body text

github - Git如何删除版本库中的一个提交?

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

PHP中文网PHP中文网2801 days ago771

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-21 10:59:13

    1. git reset --hard HEAD~1
    2. git push --force

    reply
    0
  • 黄舟

    黄舟2017-04-21 10:59:13

    :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;

    reply
    0
  • 迷茫

    迷茫2017-04-21 10:59:13

    git reset --hard HEAD~1

    git revert HEAD

    reply
    0
  • Cancelreply