git 指令

 

單獨看這個 commit id 做了什麼修改

git show CommitID

or

git diff CommitID^!

 


 

查看整個 code base 中 所有的 git project 的 status

repo forall -c 'git status'

 


 

 查看整個 code base 中 所有的 git project 的 修改部份

repo forall -c 'git diff'

 


 

revert 最後一次 commit

git revert HEAD

 

 reference:https://www.cnblogs.com/0616--ataozhijia/p/3709917.html

 


退回到某個 commit, 連同 source code 也退回。

(source code 有包含 這個 commit id)

 

1.

git checkout <commit_id>

2.

git reset --hard <commit_id>

 

如果是想要切換HEAD(工作目錄的內容)或 branch,請使用git checkout,想要開啟新branch也是使用checkout,checkout就是一個負責移動HEAD指到不同地方的指令

如果想要清除過去做過的壞事,就使用git reset,會幫你把紀錄都抹掉,消除掉,使用時請謹慎使用,reset是一個負責移動HEAD和master的指令,前者為指向當前commit,後者為歷史記錄的最新一筆commit,一旦master被移動了,雖然還可以找得回來被拋棄的記錄,但是做這件事情的時候基本上就是想要消去記錄,請謹慎使用。

reference:

https://medicineyeh.wordpress.com/2015/01/22/%E7%B4%B0%E8%AA%AAgit-reset%E5%92%8Cgit-checkout%E7%9A%84%E4%B8%8D%E5%90%8C%E4%B9%8B%E8%99%95/

 


 任務做到一半,先暫停做其它任務

1.事前先開分支,

git branch function_1

git checkout function_1

modify code

git add .

git commit

----

git checkout 另一任務的 branch

modify code

upload code

----

git checkout function_1

繼續

 


merge 來自另一 branch 的 commit

git cherry-pick commit_id


 

 看單一檔案的 修改記錄

git log file_name

 

修改的 patch

git log -p file-name

 


 

顯示 repository 在遠端 有幾個 branches

git remote show origin

 


 

修改尚未 push 的 commit message

 

git commit --amend

 

reference:https://segmentfault.com/q/1010000000761908


 將本地端的 bbb branch 推到 server 上建立 test_haha branch

git push origin bbb:test_haha

reference:https://gitbook.tw/chapters/github/delete-remote-branch.html

 

 
posted @ 2016-12-17 16:32  wangchangruei  阅读(169)  评论(0编辑  收藏  举报