记录一下我的 Git 配置和命令。真的很好用。
配置
补充下修改 Git 配置的两种方法
- 修改配置文件
- 修改命令
1
| git config --global alias.st status
|
大小写
1
| git config core.ignorecase false
|
Git push自动设置upstream
1
| git config --global push.default current
|
添加别名
- 方法1 修改配置文件
添加以下内容:
1 2 3 4 5
| [alias] st = status ci = commit co = checkout br = branch
|
方法2 命令
1
| git config --global alias.st status
|
在 unix 中,如果命令中有空格使用 单引号
1
| git config --global alias.ci 'commit -v'
|
在 Windows ,如果命令有空格或有命令行参数使用双引号
1
| c:\dev> git config --global alias.ci "commit -v"
|
命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| git branch | grep search-name
git branch --sort=-committerdate
git rebase -i [startpoint] [endpoint]
git push --force-with-lease
git stash
git stash save "message"
git stash pop
git stash apply
git stash list
git stash clear
git revert
|
参考
How do I alias commands in git? - Stack Overflow
git淫技奇巧