git高級命令使用

//實用命令

1、git stash save xxx_debug   --緩存工作區

2、git stash list   --查看緩存記錄

3、git stash clear  --清空git棧

4、git stash pop  --從緩存工作區中讀取最近一次緩存

5、git stash drop <id>  --刪去某個stash

6、git blame [file_name]  --將文件中每一行的作者、最新的變更和提交時間展示出來

7、git log --oneline  --壓縮模式顯示log

8、git reflog  查看reflog的歷史

9、git rebase -i HEAD~[number_of_commits]   --rebase把多個commit壓縮成一個

10、git cherry-pick [commit_hash]  -- 從不同的分支中撿出一個單獨的commit,並把它和你的當前分支合併

//代碼提交組合

git fetch origin

git rebase origin/master

git push origin HEAD:refs/for/master

//找回丟失

git reflog  --獲取hash

git cherry-pick [commit_hash]  --恢復丟失

//取消最後一個提交

git reset --soft HEAD^

//合併到上一次提交

git commit -a --amend -m "合併後的message" 

//把更改的文件打包出來

git diff commit_hash_a commit_hash_b --name-only ./alps/  查看2次提交之間所以的修改或者添加的文件

git diff commit_hash_a commit_hash_b --name-only ./alps/ | xargs tar -czvf upate.tar.gz

//高級應用

git shortlog   列出各位作者的提交

git log --pretty-oneline --author="Hu Genhua" 列出某位作者的提交

git checkout (branch) --(path/file)  從另一個分支拉取某個文件的內容併合併到當前分支


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章