删除分支上的文件README.md
MINGW64 /f/Git (master)
$ rmdir README.md
rmdir: failed to remove ‘README.md‘: Not a directory-------------------------------------->删目录的命令-20200307HH MINGW64 /f/Git (master)
$ rm -rf README.md-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)--------------------------------->这个是撤销删除了
deleted: README.md
no changes added to commit (use "git add" and/or "git commit -a")
-20200307HH MINGW64 /f/Git (master)
$ git add README.md
-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: README.md
-20200307HH MINGW64 /f/Git (master)
$ git commit -"clear"
fatal: could not lookup commit lear-------------------------------------------------------->所以这样做的是错的。删除一个应该用git rm
-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: README.md
-20200307HH MINGW64 /f/Git (master)
$ git restore --staged README.md---------------------------------------------------------------> 把删除撤销了
-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: README.md
no changes added to commit (use "git add" and/or "git commit -a")现在正真才是在干删除的事情:
MINGW64 /f/Git (master)
$ git rm README.md
rm ‘README.md‘
-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: README.md
-20200307HH MINGW64 /f/Git (master)
$ git commit -m"trash"
[master 4b0a1dc] trash
1 file changed, 1 deletion(-)
delete mode 100644 README.md
-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
nothing to commit, working tree clean 相关推荐
聚合室 2020-09-30
wera00 2020-08-17
DiamondTao 2020-08-17
rongxionga 2020-07-26
herohope 2020-07-19
nebulali 2020-07-05
kaixinfelix 2020-07-04
bruce 2020-06-28
YEEHOLIC 2020-06-26
KFLING 2020-06-13
贤冰 2020-06-12
qingmuluoyang 2020-06-10
Smileyou 2020-06-09
afanti 2020-06-08
Smileyou 2020-06-05
Earlyuan 2020-06-03