1. 更新git版本
git --version
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
2. git revert
git revert -n commit_id
git revert commit_id
3. git reset
git reset --hard HEAD^
git reset --soft HEAD^
git reset HEAD filename
4. git diff
git diff file_name
git diff --staged file_name
git diff --cached file_name
5. git config
git config --global i18n.logoutputencoding utf-8
git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.commitencoding utf-8 --注释:该命令表示提交命令的时候使用utf-8编码集提交
git config --global i18n.logoutputencoding utf-8 --注释:该命令表示日志输出时使用utf-8编码集显示
export LESSCHARSET = utf-8 --注释:设置LESS字符集为utf-8
set fileencodings = utf-8
set termencoding = utf-8
set encoding = utf-8
$ git config --global core.quotepath false
$ git config --global gui.encoding utf-8
$ git config --global i18n.commit.encoding utf-8
$ git config --global i18n.logoutputencoding utf-8
$ export LESSCHARSET = utf-8
6. git branch
git branch -d master
git branch -D 分支名称
git branch
git branch -r
git branch -a
git branch -v
git branch --merged
git branch --no-merged
git branch 新分支名称
7. git stash
git stash
git stash save "jack"
git stash –keep-index
git stash list
git stash show
git stash show stash@{ num}
git stash show stash@{ num} -p
git stash apply
git stash pop
git stash drop stash@{ $num }
git stash clear
8. git checkout
git checkout 分支名称
git checkout -b 新分支名称
9. git push
git push origin :分支名称
10. git配色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto