码迷,mamicode.com
首页 > 其他好文 > 详细

删除分支上的文件README.md

时间:2020-05-06 21:47:56      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:status   style   ash   user   directory   deletion   comm   and   direct   

Administrator@USER-20200307HH MINGW64 /f/Git (master)
$ rmdir README.md
rmdir: failed to remove README.md: Not a directory-------------------------------------->删目录的命令

Administrator@USER
-20200307HH MINGW64 /f/Git (master) $ rm -rf README.md


Administrator@USER
-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") Administrator@USER-20200307HH MINGW64 /f/Git (master) $ git add README.md Administrator@USER-20200307HH MINGW64 /f/Git (master) $ git status On branch master Changes to be committed: (use "git restore --staged <file>..." to unstage) deleted: README.md Administrator@USER-20200307HH MINGW64 /f/Git (master) $ git commit -"clear" fatal: could not lookup commit lear-------------------------------------------------------->所以这样做的是错的。删除一个应该用git rm Administrator@USER-20200307HH MINGW64 /f/Git (master) $ git status On branch master Changes to be committed: (use "git restore --staged <file>..." to unstage) deleted: README.md Administrator@USER-20200307HH MINGW64 /f/Git (master) $ git restore --staged README.md---------------------------------------------------------------> 把删除撤销了 Administrator@USER-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")

现在正真才是在干删除的事情:

Administrator@USER-20200307HH MINGW64 /f/Git (master)
$ git rm README.md
rm README.md

Administrator@USER-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    README.md


Administrator@USER-20200307HH MINGW64 /f/Git (master)
$ git commit -m"trash"
[master 4b0a1dc] trash
 1 file changed, 1 deletion(-)
 delete mode 100644 README.md

Administrator@USER-20200307HH MINGW64 /f/Git (master)
$ git status
On branch master
nothing to commit, working tree clean

 

删除分支上的文件README.md

标签:status   style   ash   user   directory   deletion   comm   and   direct   

原文地址:https://www.cnblogs.com/penen/p/12838791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!