Git 撤销或提交单个文件修改

撤销修改

1.先查看该Git仓库的当前状态:

git status

显示:

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
  modified:   a.txt

2.现在想撤销对a.txt文件的修改,可执行如下命令:

git checkout HEAD a.txt

 如果是带目录的:

git checkout HEAD config/index.js

提交单个文件:

git add 文件名
// 比如
git add src/goods.vue

多个文件的话,可以多次git add 文件名。

然后提交:

git commit
git push
原文地址:https://www.cnblogs.com/joe235/p/12370480.html