mkdir /home/gitroot
进入目录
cd /home/gitroot
初始化仓库
git init
创建一个文件
echo 123456 >> 1.txt
把1.txt添加到仓库
git add 1.txt
提交到仓库
git commit -m "add new file 1.txt"
查看状态
git status
再次修改文件
echo 111111 >> 1.txt
查看仓库状态
git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: 1.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
对比仓库
git diff 1.txt
diff --git a/1.txt b/1.txt
index f7c6dd0..1341f39 100644
--- a/1.txt
+++ b/1.txt
@@ -1 +1,2 @@
123456
+11111
检出1.txt
git checkout -- 1.txt
再次查看状态
git status
# On branch master
nothing to commit (working directory clean)