F:\Test>git init #初始化 Initialized empty Git repository in F:/Test/.git/ F:\Test>git add . #添加文件 F:\Test>git commit -m 'init' #提交 [master (root-commit) 0b9520a] 'init' 2 files changed, 4 insertions(+) create mode 100644 dev.txt create mode 100644 test.txt F:\Test>git checkout -b dev --新建並切換分支 Switched to a new branch 'dev' F:\Test>git diff #更改文件,比較文件差別 WARNING: terminal is not fully functional diff --git a/dev.txt b/dev.txt index d62bb90..a21f2e9 100644 --- a/dev.txt +++ b/dev.txt @@ -1,2 +1,5 @@ init -dev-edit \ No newline at end of file +dev-edit + + +dev-edit-2015-08-05 \ No newline at end of file F:\Test>git commit -a -m 'edit-dev' #提交 [dev 9f224fd] 'edit-dev' 1 file changed, 4 insertions(+), 1 deletion(-) F:\Test>git checkout master #切換到主分支 Switched to branch 'master' F:\Test>git diff #更改文件,並對比差別 WARNING: terminal is not fully functional diff --git a/dev.txt b/dev.txt index d62bb90..719fd72 100644 --- a/dev.txt +++ b/dev.txt @@ -1,2 +1,4 @@ init -dev-edit \ No newline at end of file +dev-edit + +edt-master-2018-08-05 \ No newline at end of file F:\Test>git commit -a -m 'edit-master-dev' #提交併保存已更改的文件 [master dbeec1c] 'edit-master-dev' 1 file changed, 3 insertions(+), 1 deletion(-) F:\Test>git status On branch master nothing to commit, working directory clean F:\Test>git checkout dev dev.txt #在master中合併 並覆蓋dev分支中的dev.txt文件 F:\Test>git status #當前master分支狀態,由於dev.txt是直接從dev分支直接覆蓋而來,因此可能須要手動合併衝突 On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: dev.txt F:\Test>git diff WARNING: terminal is not fully functional - (press RETURN) F:\Test> F:\Test>git diff dev.txt #查看dev.txt跟當前分支的差別,由於已經提交到暫存區,因此這裏沒有顯示出差別 WARNING: terminal is not fully functional - (press RETURN) F:\Test>git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: dev.txt F:\Test>git citool #使用Gui查看差別