Git-git删除文件夹/文件(删除/不删除本地文件/文件夹)

一顿操作就完事了:

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ touch test

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ mkdir test2

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ mkdir pro

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ mv test pro/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ mv test2/ pro/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ ls
 AlbumArt_{B5020207-474E-4720-2C44-A52C91F98700}_Large.jpg
 AlbumArt_{B5020207-474E-4720-2C44-A52C91F98700}_Small.jpg
 AlbumArtSmall.jpg
'Camera Roll'/
 desktop.ini
 Folder.jpg
 pro/
'Saved Pictures'/
 Screenshots/
 timg.jpg
'WaveSideBar-master (1)'/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures
$ cd pro/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro
$ git init
Initialized empty Git repository in C:/Users/lieyun_android/Pictures/pro/.git/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git add .

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git commit -m "提交初始化工程"
[master (root-commit) ec330cb] 提交初始化工程
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git rm test
rm 'test'

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ ls
test2/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git commit -m "删除仓库和本地文件"
[master dfe5e12] 删除仓库和本地文件
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 test

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git rm -r --cached test2/
fatal: pathspec 'test2/' did not match any files

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ cd test2/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro/test2 (master)
$ touch tt

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro/test2 (master)
$ git add .

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro/test2 (master)
$ git commit -m "test2文件夹新增文件tt"
[master 594e6d8] test2文件夹新增文件tt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test2/tt

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro/test2 (master)
$ cd ..

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git rm -r --cached test2/
rm 'test2/tt'

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git commit -m "删除仓库关联文件夹test2"
[master 8f26183] 删除仓库关联文件夹test2
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 test2/tt

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ ls
test2/

lieyun_android@DESKTOP-JM7KND2 MINGW64 ~/Pictures/pro (master)
$ git status
On branch master
Untracked files:
  (use "git add ..." to include in what will be committed)

        test2/

nothing added to commit but untracked files present (use "git add" to track)

So, 重点就是:

image

你可能感兴趣的:(Git-git删除文件夹/文件(删除/不删除本地文件/文件夹))