欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

git操作:撤销更改的文件

程序员文章站 2023-11-08 10:45:10
在没有git add之前: #撤销所有更改 git checkout . #撤销指定文件的更改 git checkout -- myfile.txt ......

在没有git add之前:

#撤销所有更改
git checkout .

#撤销指定文件的更改
git checkout -- myfile.txt

在git add之后:

git reset head myfile.txt

git push 之后:

git reset --hard  comitthash
# git log --online可以查看hashid 返回到某个节点,不保留修改

git reset --soft  comitthash
# git log --online可以查看hashid 返回到某个节点,保留修改