git 配置了解这些就够了
1. config
Git相关的配置文件有三个
1. /etc/gitconfig:包含了适用于系统所有用户和所有项目的值。 --system
2.~/.gitconfig:只适用于当前登录用户的配置。 --global
3. 位于git项目目录中的.git/config:适用于特定git项目的配置。 --local
git config --system -e 就可以编辑了
[core]
excludesfile = ~/.gitignore
legacyheaders = false # >git 1.5
quotepath = false
[user]
# name = your name
# email = your@name
[mergetool]
keepBackup = true
[push]
default = simple # [ matching | simple ]
[color]
ui = auto
interactive = auto
[repack]
usedeltabaseoffset = true # >git 1.5
[alias]
s = status
a = !git add . && git status
au = !git add -u . && git status
aa = !git add . && git add -u . && git status
c = commit
cm = commit -m
ca = commit --amend # careful
ac = !git add . && git commit
acm = !git add . && git commit -m
l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
ll = log --stat --abbrev-commit
lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
d = diff
master = checkout master
spull = svn rebase
spush = svn dcommit
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort
[include] # as of 1.7.10 https://github.com/git/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0
path = ~/.gitcinclude
path = .githubconfig
path = .gitcredential
#[github]
# user =
# token =
[diff]
# git does copy/rename *detection*. if you want it to track copies/renames:
# http://stackoverflow.com/questions/1043388/record-file-copy-operation-with-git
# renames = copies
[diff "exif"]
textconv = exif
[credential]
helper = osxkeychain
2. 一些git命令常用
git push new-branch
git push tag
git push ~
git tag publish/x.x.x
git push origin publish/x.x.x:publish/x.x.x
git push origin —delete branchName 删除branch
git push origin :<branchName>
git push origin —delete tag tagName 删除tag
git tag -d <tagname>ta
git push origin :refs/tags/<tagname>
git rm --cached -r . 清缓存git命令
git reset [--hard|soft|mixed|merge|keep] [commit|HEAD] 回滚
git remote prune origin // 远程删除了分支,本地同步
2. 一些问题
报错 fatal: refusing to merge unrelated histories
命令后面加参数 --allow-unrelated-histories
参考链接
2、git - 默认行为的"git push"没有指定一个分支
4、Git忽略提交规则 - .gitignore配置运维总结
欢迎交流~