查看仓库的状态
$ git statusOn branch masterNo commits yetUntracked files: # 未被追踪的问题(use "git add <file>..." to include in what will be committed)hello.txtnothing added to commit but untracked files present (use "git add" to track)
添加文件到暂存区
git add [文件名]
$ git add hello.txtwarning: LF will be replaced by CRLF in hello.txt. # git将CRLF替换成LF,windows里面换行符是CRLF,linux里面换行符是LFThe file will have its original line endings in your working directory
查看文件状态
root@ZJJ MINGW64 /f/projectDemo (master)$ git statusOn branch masterNo commits yetChanges to be committed:(use "git rm --cached <file>..." to unstage)new file: hello.txt # 文件被git追踪到了,这个文件只是在暂存区里面,此时还没将这个文件保存到历史版本root@ZJJ MINGW64 /f/projectDemo (master)
将文件从暂存区里面删除掉
git rm —cached [文件名]
root@ZJJ MINGW64 /f/projectDemo (master)$ git rm --cached hello.txtrm 'hello.txt'
这个删除只是把文件从暂存区里面删除了,工作区里面还是有的,你用ls查看,发现文件还是在你工作区里面的
root@ZJJ MINGW64 /f/projectDemo (master)$ lshello.txt
