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)  从另一个分支拉取某个文件的内容并合并到当前分支


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