$ git config --global user.name 'user_name'
$ git config --global user.email 'user_email'
$ git config --global http.sslCAInfo /XXXX/XXX/XXX.crt
$ git config --global --list
$ git config --global http.sslVerify "false"
$ git config --global credential.helper store
$ git config --global alias.hist "log --color --graph --pretty=format:'%Cred%h%Creset - %Cgreen(%ci)%Creset %s %C(bold blue)<%an>%Creset%C(yellow)%d%Creset' --abbrev-commit"
$ git config --global alias.recover '!git clean -df && git reset HEAD --hard'
$ git config --global alias.updbr '!git checkout master && git branch -D feature/code_association_rule_mining && git pull --ff-only && git checkout feature/code_association_rule_mining'
$ git log --author='author_name' --before='yyyy-mm-dd hh:mm:ss' --after='yyyy-mm-dd hh:mm:ss' --first-parent
$ git log --follow -- 'filepath'
$ git revert 'commit-id' --no-merge
# calculate number of lines of code changed
$ git diff --stat OR $ git log --stat
$ git diff 'from'..'to' -- 'filepath'
# pull = fetch + merge
$ git fetch 'repo' 'branch'
$ git diff 'from'..'to' -- 'filepath'
# with some process...
$ git merge '@{u}'
$ git tag 'light-weight tag name' 'commit-ish'
$ git tag -a 'anotated tag name' -m 'tag message'
$ git push 'repo' 'tag name'
# rename branch locally and remotely
$ git branch -m ['old_br_name'] 'new_name'
$ git push 'repo' :'old_br_name'
$ git push 'repo' -u 'new_name'
# remove remote branch
$ git push -d 'repo' 'branch'
$ git remote prune origin # or: git fetch -p
$ git rebase --onto 'target_commit-ish' 'start_commit-ish(exclude)' 'end_commit-ish(include)'
$ git rebase --quit
$ git remote add origin 'url'
# to see commit that certain-branch doesn't have but current branch does have
$ git cherry -v 'certain-branch'
# 1st merge of commit-ish
$ git log --merges 'commit-ish'..HEAD --ancestry-path --pretty=format:'%H %ct' | tail -1
# to see all commit id of merges that merges into branch of name "br_name"
$ git log --pretty=format:%H --merges --first-parent 'br_name'
# to see changing statistics of certain commit
$ git show 'commit-id' --pretty=format:%aI --numstat
$ git log -p --merges --first-parent 'br_name'
# to see history of a specific line of a file
$ git log -L 'startline','endline':'filepath'
# to see merges from a commit until now
$ git log --reverse --merges 'commit-id'..HEAD
$ git diff --unified=
# extract commits to patch file
$ git format-patch -4 HEAD
# apply commits
$ git am *.patch
# change remote repository of `master` branch
$ git remote rename origin old
$ git remote add origin 'repositiory-url.git'
$ git config branch.master.remote origin
# GIT LFS smudge报错:
# error: external filter 'git-lfs filter-process' failed
# fatal: DataSource/codex/phoenix-5.0.0.3.0.1.0-187-client.jar: smudge filter lfs failed
# 规避方法:
# Skip smudge - We'll download binary files later in a faster batch
$ git lfs install --skip-smudge
# Do git clone here
$ git clone ...
# Fetch all the binary files in the new clone
$ git lfs pull
# Reinstate smudge
$ git lfs install --force
# Clone repo without SSL verify:
$ git -c http.sslVerify=false clone 'repositiory-url.git'
$ git config http.sslVerify "false"
标签:git,name,--,手册,命令,Git,branch,commit,config
From: https://www.cnblogs.com/LexLuc/p/16867358.html