Miscellaneous notes on git practical commands

Merging using conflict resolution will avoid simple automatic merging

git merge origin/dev --strategy=resolve

Clean up the local branch that has been merged into dev

git branch --merged | grep -v 'dev' | xargs -n 1 git branch -d

Branch cleanup

Git deletes local useless branches_dearfulan's blog - CSDN blog_git deletes local invalid branches

git fetch -p
git remote prune origin

View the most recent common ancestor of two branches

git merge-base [-a|--all] <commit> <commit>

The branch or TAG that contains a commit

git branch --contains <commit>
git branch -r --contains <commit>
git tag --contains <commit>

Count the number of git commits

git rev-list --count HEAD

git lists the commit numbers of HEAD

git rev-parse HEAD

# 如果只是查看,则直接使用 show 命令就可以
git show HEAD

git alias

git config --global alias.co checkout
git config --global alias.lg log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Line break problem

Git multi-platform newline problem (LF or CRLF)

Submit checkout is not converted

git config --global core.autocrlf false

Allow submission of files containing mixed newlines

git config --global core.safecrlf false

View commit log

git reflog show --color --abbrev-commit --all --pretty=oneline --date=short --after="2020-05-22" | grep 'commit' | grep -v 'refs'

empty commit

git commit -m "version + 2" --allow-empty

other

Git LFS Operation Guide

Insert image description here

Guess you like

Origin blog.csdn.net/lj22377/article/details/134980402