git手记

alias别名

总结了常用的git命令,便捷别名,vim ~/.gitconfig

[gui]
[user]
  name = Alex F. Zhang
  email = ***[email protected]
[difftool "sourcetree"]
  cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
  cmd = "'' "
  trustExitCode = true
[alias]
  co = checkout
  br = branch
  st = status
  ci = commit
  fa = fetch --all
  pl = pull
  ps = push
  unstage = reset head^
  last = log -1 --name-only HEAD
  conf = config -l
  alias = config -l
  rb = branch -r
  tr = log -20 --oneline --graph --decorate
  log10 = log -10 --oneline --graph --decorate
  mg = merge --no-commit
  logaz = log --name-status --no-merges --author=\"author\" --pretty=\"%h, %s, %an\" # no merges
  mm = log -n 10 --oneline --author=\"author\" --pretty=\"%s\" # commit history messages
  logll = log --name-status --no-merges --author=\"linaliu\" --pretty=\"%Cgreen%H%Creset, %s, %an\"
  logsr = log -m --name-only --date=iso --pretty=\"%h, %s, %an, %ad\"
  loggrprw = log --name-only --author=\"ralphwang|Alex Zhang|linaliu\"
  ch = log -10 --author=\"Alex F. Zhang\" --pretty=\"%s\"
  logf = "!f() { git log --date=iso --pretty=\"%n%h|%an|%ad||%s\" -- \"${1}\"; }; f" # log for specified file
  loga = "!f() { git log --name-status --no-merges --date=iso --pretty=\"%n%h|%an|%ad|%s\" --author=\"${1}\"; }; f" # log for specified author
  log1 = log --no-merges --oneline --graph --decorate
  mdiff = "!f() { git diff --diff-filter=d --name-only ${1}^1...${1}^2; }; f"
  ndiff = "!f() { git diff --diff-filter=d --name-only ${1}^...${1}; }; f"
  logn = "!f() { git log -${1} ${2} --date-order --oneline --graph --decorate; }; f"
  hp = "!f() { git commit -a -m \"${1}\"; git push; }; f"
  ca = "!f() { git commit -a -m \"${1}\"; }; f" # git commit
[grep]
  extendedRegexp = true
[merge]
  tool = vscode
[mergetool "vscode"]
  cmd = "code --wait "
[diff]
  tool = bc3
[difftool "bc3"]
  cmd = "\"/c/Program Files/Beyond Compare 4/BComp.exe\"" \"$LOCAL\" \"$REMOTE\"
  trustExitCode = true
[gui]
[filesystem "Oracle Corporation|11.0.2|-635900934"]
  timestampResolution = 12001 microseconds
  minRacyThreshold = 0 nanoseconds
[http]
[push]
  default = current
[guitool "pull"]
  cmd = git pull
  noconsole = yes
[core]
  excludesfile = C:\\Users\\alexzhang\\Documents\\gitignore_global.txt
  autocrlf = false
  editor = vim
  eol = lf

GIT Bash快捷命令

alias c='clear'
alias d='. sd'
alias g='git'
alias l='git pull'
alias s='git push'
alias gst='git stash'
alias gsa='git stash apply'
alias log='git log --oneline --graph --decorate --date-order'

submodules

参考:Git-Submodules

git clone --recurse-submodules uri
git submodule update --init # already cloned

ignore __pycache__ folder

add __pycache__ into .git/info/exclude file

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
parent_folder/__pycache__

配置代理

[user]
	name = your_id
	email = your_email
[http]
	proxy = http://domain_id:password@proxy_host:port/
	sslVerify = false
[https]
	proxy = http://domain_id:password@proxy_host:port/
	sslVerify = false

你可能感兴趣的:(Git,git)