删除文件
背景
# 查看当前文件列表
$ ls
file1.txt file2.txt file3.txt newFile.txt test.txt
# 新建待删除文件
$ touch delete.txt
# 再次查看当前文件列表,确保新建文件成功
$ ls
delete.txt file2.txt newFile.txt
file1.txt file3.txt test.txt
# 查看当前文件状态: 新文件 `delete.txt` 还没被跟踪
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
delete.txt
nothing added to commit but untracked files present (use "git add" to track)
# 添加新文件 `delete.txt`
$ git add delete.txt
# 查看文件状态: 已添加到暂存区,待提交到版本库
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: delete.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
# 提交新文件 `delete.txt`
$ git commit -m "add delete.txt"
[master 7df386a] add delete.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 delete.txt
# 再次查看文件状态: 已经没有新文件 `delete.txt` 的更改信息
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
nothing added to commit but untracked files present (use "git add" to track)
$ 小结
最后更新于