git status 只能檢視區域狀態的不同,不能檢視檔案的內容不同之處
[root@git ~/git_test]
# git status
# on branch master
# changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
## modified: a.txt
#no changes added to commit (use "git add" and/or "git commit -a"
)#改變了工作目錄中a.txt檔案中的內容
[root@git ~/git_test]
# echo "111111111" >> a.txt
[root@git ~/git_test]
# git status
# on branch master
# changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
## modified: a.txt
#no changes added to commit (use "git add" and/or "git commit -a"
)#進行比對工作目錄和暫存區中檔案內容的不同之處
[root@git ~/git_test]
# git diff .
diff --git a/a.txt b/a.txt
index e69de29..bb81b3c 100644
--- a/a.txt
+++ b/a.txt
@@ -0,0 +1 @@
+111111111
[root@git ~/git_test]
# git add . #新增到暫存區
[root@git ~/git_test]
# git status
# on branch master
# changes to be committed:
# (use "git reset head ..." to unstage)
## modified: a.txt
#[root@git ~/git_test]
# git diff . #顯示工作目錄和暫存區中的檔案內容是一致的
[root@git ~/git_test]
# #對比暫存區和本地倉庫的檔案內容不同之處
[root@git ~/git_test]
# git diff --cached .
diff --git a/a.txt b/a.txt
index e69de29..bb81b3c 100644
--- a/a.txt
+++ b/a.txt
@@ -0,0 +1 @@
+111111111
#將資料提交到本地倉庫
[root@git ~/git_test]
# git commit -m "modify a.txt 1"
[master 8e84d34] modify a.txt 1
1 file changed, 1 insertion(+)
[root@git ~/git_test]
# git status
# on branch master
nothing to commit, working directory clean
[root@git ~/git_test]
# git diff --cached .
[root@git ~/git_test]
#
git 使用vimdiff 格式顯示比對檔案
可以指定外邊的diff工具來顯示檔案差異,可以使用 git difftool tool help 檢視difftool可用的工具 如果不指定預設的difftool工具,需要使用 extcmd 引數指定具體的diff工具,比如 git difftool extcmd vimdiff cache pri...
批量檔案比對
前幾天就有研發人員發現了相同網元的兩台機器的配置檔案有些不同的地方,今天無聊就幫研發人員將這些差異比對出來。研發自己有比較工具,這個指令碼太複雜,而且為了配合使用這個指令碼還寫了9頁的指導文件,因為懶得看文件和熟悉那個超複雜的指令碼,就用我自己的方式來比對。本著懶人原則,用最簡單的語句,搞定最複雜的...
python 檔案比對
coding utf 8 class data def init self,a b self.a a self.b b def return data self return self.a,self.b class createobject def init self,class name null...