How to cancel a local git commit

前端 未结 6 2073
抹茶落季
抹茶落季 2021-01-29 17:20

My issue is I have changed a file eg: README, added a new line \'this for my testing line\' and saved the file, then I issued the following commands

 gi         


        
6条回答
  •  执笔经年
    2021-01-29 17:32

    The first thing you should do is to determine whether you want to keep the local changes before you delete the commit message.

    Use git log to show current commit messages, then find the commit_id before the commit that you want to delete, not the commit you want to delete.

    If you want to keep the locally changed files, and just delete commit message:

    git reset --soft commit_id

    If you want to delete all locally changed files and the commit message:

    git reset --hard commit_id

    That's the difference of soft and hard

提交回复
热议问题