Git放弃本地修改(只修改|已经add|已经commit)
作者:互联网
1、本地文件已经修改,但是没有使用git add .命令,此时通过git status查看(只修改)

可以通过以下命令放弃修改
- 放弃单个文件
git restore bootstrap表格/隔行变色的表格.html
- 放弃整个文件夹
git restore bootstrap表格
- 放弃所有修改
git restore .
2、本地代码修改后,使用了git add .命令,此时通过git status查看(已经add)

可以通过以下命令放弃修改,放弃后会回到第一步,修改的代码不会被删除。
- 放弃单个文件
git restore --staged bootstrap表格/隔行变色的表格.html
- 放弃整个文件夹
git restore --staged bootstrap表格
- 放弃所有修改
git restore --staged .
3、本地代码修改后,使用了git add .命令和git commit -m命令,此时通过git status查看(已经commit)
可以通过以下命令放弃修改
git reset HEAD^
备注:此时仅保存了修改(恢复到了第一步)

标签:restore,Git,表格,修改,add,git,放弃 来源: https://www.cnblogs.com/rainbow-tan/p/15234534.html