Tips: 本文创建于2016年5月11日,已超过 2 年,内容或图片可能已经失效!
-> [email protected] ~/git ☺ git init git_repo  
Initialized empty Git repository in /home/liuhonghe/git/git_repo/.git/  
-> [email protected] ~/git ☺ cd git_repo   
-> [email protected] ~/git/git_repo git:(master) ☺ echo "Initial commit" > master.txt  
-> [email protected] ~/git/git_repo git:(master) ✗ ☺ git add .  
-> [email protected] ~/git/git_repo git:(master) ✗ ☺ git commit -m "Initial commit on master"  
[master (root-commit) f699140] Initial commit on master  
 Committer: liuhonghe <[email protected](none)>  
  
 1 files changed, 1 insertions(+), 0 deletions(-)  
 create mode 100644 master.txt  
-> [email protected] ~/git/git_repo git:(master) ☺ echo "Second commit on master" >> master.txt   
-> [email protected] ~/git/git_repo git:(master) ✗ ☺ git add .  
-> [email protected] ~/git/git_repo git:(master) ✗ ☺ git commit -m "Second commit on master"  
[master e93b143] Second commit on master  
 Committer: liuhonghe <[email protected](none)>  
  
 1 files changed, 1 insertions(+), 0 deletions(-)  
# 添加新分支  
-> [email protected] ~/git/git_repo git:(master) ☺ git branch test  
-> [email protected] ~/git/git_repo git:(master) ☺ git checkout test  
Switched to branch 'test'  
-> [email protected] ~/git/git_repo git:(test) ☺ echo "Initial commit on test" >> master.txt   
-> [email protected] ~/git/git_repo git:(test) ✗ ☺ touch test.txt  
-> [email protected] ~/git/git_repo git:(test) ✗ ☺ git add .  
-> [email protected] ~/git/git_repo git:(test) ✗ ☺ git commit -m "Initial commit on test"  
[test df641d6] Initial commit on test  
 Committer: liuhonghe <[email protected](none)>  
  
 1 files changed, 1 insertions(+), 0 deletions(-)  
 create mode 100644 test.txt  
-> [email protected] ~/git/git_repo git:(test) ☺ git checkout master  
Switched to branch 'master'  
-> [email protected] ~/git/git_repo git:(master) ☺ git branch  
* master  
  test  
# git 两种标签模式,一个普通tag,一个tag对象  
-> [email protected] ~/git/git_repo git:(master) ☺ git log --oneline --decorate --graph --all   #查看历史记录  
* df641d6 (test) Initial commit on test  
* e93b143 (HEAD, master) Second commit on master  
* f699140 Initial commit on master  
-> [email protected] ~/git/git_repo git:(master) ☺ git tag "v0" f699140  
-> [email protected] ~/git/git_repo git:(master) ☺ git tag  
v0  
-> [email protected] ~/git/git_repo git:(master) ☺ git tag -a "INITIAL_COMMIT" f699140  
-> [email protected] ~/git/git_repo git:(master) ☺ git tag  
INITIAL_COMMIT  
v0  
-> [email protected] ~/git/git_repo git:(master) ☺ git config --global alias.lol "log --oneline --decorate --graph --all"  
-> [email protected] ~/git/git_repo git:(master) ☺ git lol  
* df641d6 (test) Initial commit on test  
* e93b143 (HEAD, master) Second commit on master  
* f699140 (v0, tag: INITIAL_COMMIT) Initial commit on master  
  
-> [email protected] ~/git/git_repo git:(master) ☺ git show v0  
commit f6991405ec8cf44e73d751f7fede05e0a65264e8  
Author: liuhonghe <[email protected](none)>  
Date:   Wed May 11 14:07:14 2016 +0800  
  
    Initial commit on master  
  
diff --git a/master.txt b/master.txt  
new file mode 100644  
index 0000000..5852f44  
--- /dev/null  
+++ b/master.txt  
@@ -0,0 +1 @@  
+Initial commit  
  
-> [email protected] ~/git/git_repo git:(master) ☺ git show INITIAL_COMMIT  
tag INITIAL_COMMIT  
Tagger: liuhonghe <[email protected]>  
Date:   Wed May 11 14:24:59 2016 +0800  
  
Initial commit  
  
commit f6991405ec8cf44e73d751f7fede05e0a65264e8  
Author: liuhonghe <[email protected](none)>  
Date:   Wed May 11 14:07:14 2016 +0800  
  
    Initial commit on master  
  
diff --git a/master.txt b/master.txt  
new file mode 100644  
index 0000000..5852f44  
--- /dev/null  
+++ b/master.txt  
@@ -0,0 +1 @@  
+Initial commit  
  
-> [email protected] ~/git/git_repo git:(master) ☺ git checkout v0  
Note: checking out 'v0'.  
  
You are in 'detached HEAD' state. You can look around, make experimental  
changes and commit them, and you can discard any commits you make in this  
state without impacting any branches by performing another checkout.  
  
If you want to create a new branch to retain commits you create, you may  
do so (now or later) by using -b with the checkout command again. Example:  
  
  git checkout -b new_branch_name  
  
HEAD is now at f699140... Initial commit on master  
-> [email protected] ~/git/git_repo git:(f699140) ☺ git checkout -b fix_v0  
Switched to a new branch 'fix_v0'  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ echo "stash1" >> master.txt  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ 1☺ git stash save "stash1"  
Saved working directory and index state On fix_v0: stash1  
HEAD is now at f699140 Initial commit on master  
-> [email protected] ~/git/git_repo git:(master) ☺ git stash list   #从其他分支切回来的情况  
[email protected]{0}: On fix_v0: stash1  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ git stash pop --index [email protected]\{0\}    #pop会把选择的stash清除  
# On branch fix_v0  
# Changes to be committed:  
#   (use "git reset HEAD <file>..." to unstage)  
#  
#       modified:   master.txt  
#  
Dropped [email protected]{0} (26beefc418ce0534740bcfcafe17101a10bb19d2)  
  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash save "stash1"   #恢复回去  
Saved working directory and index state On fix_v0: stash1  
HEAD is now at f699140 Initial commit on master  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ git stash list  
[email protected]{0}: On fix_v0: stash1  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ git stash apply --index [email protected]\{0\}                                                                                                                                             
# On branch fix_v0  
# Changes to be committed:  
#   (use "git reset HEAD <file>..." to unstage)  
#  
#       modified:   master.txt  
#  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ cat master.txt   
Initial commit  
stash1  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash list  
[email protected]{0}: On fix_v0: stash1  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash drop [email protected]\{0\}   
Dropped [email protected]{0} (e47e2f40848e9b05561be1a2bc7cc4a6cd06256f)  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash list  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash clear    #清理所有  
  
# 分支合并  
-> [email protected] ~/git/git_repo git:(fix_v0) ✗ ☺ git stash save  
Saved working directory and index state WIP on fix_v0: f699140 Initial commit on master  
HEAD is now at f699140 Initial commit on master  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ git stash list  
-> [email protected] ~/git/git_repo git:(fix_v0) ☺ git checkout master  
Switched to branch 'master'  
-> [email protected] ~/git/git_repo git:(master) ☺ git checkout -b test_merge  
Switched to a new branch 'test_merge'  
-> [email protected] ~/git/git_repo git:(test_merge) ☺ echo "Initial commit on test_merge" >> master.txt  
-> [email protected] ~/git/git_repo git:(test_merge) ✗ ☺ git add .  
-> [email protected] ~/git/git_repo git:(test_merge) ✗ ☺ git commit -m "Initial commit on test_merge"  
[test_merge 8bb97f0] Initial commit on test_merge  
 1 files changed, 3 insertions(+), 0 deletions(-)  
 create mode 100644 master.txt  
-> [email protected] ~/git/git_repo git:(test_merge) ☺ git lol  
* 8bb97f0 (HEAD, test_merge) Initial commit on test_merge  
* 78cd3a1 Initial commit on test_merge  
| *   5b37bf7 (refs/stash) WIP on fix_v0: f699140 Initial commit on master  
| |\    
| | * ae71b98 index on fix_v0: f699140 Initial commit on master  
| |/    
| | * df641d6 (test) Initial commit on test  
| |/    
|/|     
* | e93b143 (master) Second commit on master  
|/    
* f699140 (v0, tag: INITIAL_COMMIT, fix_v0) Initial commit on master  
-> [email protected] ~/git/git_repo git:(test_merge) ☺ git checkout master  
Switched to branch 'master'  
-> [email protected] ~/git/git_repo git:(master) ☺ git merge test_merge  
Updating e93b143..8bb97f0  
Fast-forward  
 master.txt |    1 +  
 1 files changed, 1 insertions(+), 0 deletions(-)  
-> [email protected] ~/git/git_repo git:(master) ☺ git lol  
* 8bb97f0 (HEAD, test_merge, master) Initial commit on test_merge  
* 78cd3a1 Initial commit on test_merge  
* 19070c8 Initial commit on test_mergi  
| *   5b37bf7 (refs/stash) WIP on fix_v0: f699140 Initial commit on master  
| |\    
| | * ae71b98 index on fix_v0: f699140 Initial commit on master  
| |/    
| | * df641d6 (test) Initial commit on test  
| |/    
|/|     
* | e93b143 Second commit on master  
|/    
* f699140 (v0, tag: INITIAL_COMMIT, fix_v0) Initial commit on master  
-> [email protected] ~/git/git_repo git:(master) ☺ git merge test  
Auto-merging master.txt  
CONFLICT (content): Merge conflict in master.txt  
Automatic merge failed; fix conflicts and then commit the result.  
-> [email protected] ~/git/git_repo git:(master) ✗ 1☺ cat master.txt   
Initial commit  
Second commit on master  
<<<<<<< HEAD  
Initial commit on test_merge  
=======  
Initial commit on test  
>>>>>>> test  
# 处理冲突,重新add->commit