Last active
May 21, 2018 03:16
-
-
Save moonrailgun/91f5fbc95285fcc6ad3f8f39e1dca6a9 to your computer and use it in GitHub Desktop.
Git Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout -b master origin/master # 根据远程分支创建新分支 | |
# git log 别名 | |
git config --global alias.lm "log --no-merges --color --date=format:'%Y-%m-%d %H:%M:%S' --author='你的名字!自己修改!' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
git config --global alias.lms "log --no-merges --color --stat --date=format:'%Y-%m-%d %H:%M:%S' --author='你的名字!自己修改!' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
git config --global alias.ls "log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
git config --global alias.lss "log --no-merges --color --stat --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
# 远程回滚方式 | |
# 假设git log | |
# 8 | |
# 7 | |
# 6 | |
# 5 | |
# 4 | |
# 3 | |
# 2 | |
# 1 | |
# 想要回滚到提交4 | |
git revert 4...8 | |
# or | |
git revert 4...HEAD | |
# or | |
git reset --hard 4 | |
git reset --soft 8 | |
git commit -m 'Reverted 5 6 7 8' | |
# 查看一个文件的修改历史记录 | |
git log -p [filepath] | |
# 查看各个branch之间的关系图 | |
# --decorate 标记会让git log显示每个commit的引用(如:分支、tag等) | |
# --oneline 一行显示 | |
# --simplify-by-decoration 只显示被branch或tag引用的commit | |
# --all 表示显示所有的branch,这里也可以选择,比如我指向显示分支ABC的关系,则将--all替换为branchA branchB branchC | |
git log --graph --decorate --oneline --simplify-by-decoration --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment