How to cancel a local git commit

前端 未结 6 2019
抹茶落季
抹茶落季 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:41

    You can tell Git what to do with your index (set of files that will become the next commit) and working directory when performing git reset by using one of the parameters:

    --soft: Only commits will be reseted, while Index and the working directory are not altered.

    --mixed: This will reset the index to match the HEAD, while working directory will not be touched. All the changes will stay in the working directory and appear as modified.

    --hard: It resets everything (commits, index, working directory) to match the HEAD.

    In your case, I would use git reset --soft to keep your modified changes in Index and working directory. Be sure to check this out for a more detailed explanation.

提交回复
热议问题