删除分支上的文件README.md

Posted penen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了删除分支上的文件README.md相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

Git 分支的创建、切换、合并以及解决冲突、删除

github中的 README.md 内容怎么换行

checkout

git项目提交及分支操作命令

git(三)分支操作

git --- 新建分支