Git/Github GitBash 3 working directory/staging area(index)/respository

working directory 本地工作目录
staging area(index)
respository 仓库
git add . (working directory -> staging area)
git commit (staging area -> respository)
commit生效后,只要.git没有丢失,工作目录的文件只是快照可以任意删除。


$ touch 1.txt
$ ls -alh
total 8.0K
drwxr-xr-x 1 desktop 197121 0 八月 8 16:07 ./
drwxr-xr-x 1 desktop 197121 0 八月 8 15:29 ../
drwxr-xr-x 1 desktop 197121 0 八月 8 15:42 .git/
-rw-r--r-- 1 desktop 197121 0 八月 8 16:07 1.txt


$ git add .
$ git commit -m 'v1.0'
$ rm -f 1.txt
$ ls -alh
total 8.0K
drwxr-xr-x 1 desktop 197121 0 八月 8 16:10 ./
drwxr-xr-x 1 desktop 197121 0 八月 8 15:29 ../
drwxr-xr-x 1 desktop 197121 0 八月 8 16:08 .git/


$ git checkout -f HEAD
$ ls -alh
total 8.0K
drwxr-xr-x 1 desktop 197121 0 八月 8 16:11 ./
drwxr-xr-x 1 desktop 197121 0 八月 8 15:29 ../
drwxr-xr-x 1 desktop 197121 0 八月 8 16:11 .git/
-rw-r--r-- 1 desktop 197121 0 八月 8 16:11 1.txt


猜你喜欢

转载自www.cnblogs.com/dailycode/p/9443520.html