# 设置
$ git config --global user.name "jack"
$ git config --global user.email "jack@test.com"
# 查看
$ git config --global user.name
$ git config --global user.email
$ cd my-project
# 设置
$ git config user.name "john"
$ git config user.email "john@test.com"
# 查看
$ git config user.name
$ git config user.email
$ git remote -v
git init
git remote add origin git@github.com:scottliu2011/test.git
git add .
git commit -m "init files"
git push -u origin master
git branch
git branch -a
git checkout -b new-feature origin/master
git push origin new-feature:new-feature
git checkout hot-fix
git tag tag-v3
git push origin tag-v3
git tag -d tag-v3
git add test.md test.txt
git reset head
# 或者只针对某个文件撤销
git reset head test.txt
# 撤销刚刚提交的代码
# 软撤销 恢复到暂存区
$ git reset --soft head^
# 硬撤销 丢弃代码修改
$ git reset --hard head^
$ git log
# 找到需要撤销的COMMIT_ID
$ git reset COMMIT_ID
$ git reset --soft COMMIT_ID
$ git reset --hard COMMIT_ID
git checkout -b dev
# add & commit
git checkout master
git merge dev
git push
git remote rm origin
git remote add origin git@github.com:scottliu2011/new-test.git
git merge --abort
git reset --merge
git pull
# 查看本地代理软件socks5端口
git config --global http.proxy socks5://127.0.0.1:10000
# 检查配置是否成功
git config --global -e
# 开始使用代理clone代码
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# 使用完成后取消代理配置
git config --global --unset http.proxy
alias ga=‘git add‘
alias gf=‘git fetch‘
alias gp=‘git pull‘
alias gc=‘git commit -m‘
alias gps=‘git push‘
alias gck=‘git checkout‘
alias gb=‘git checkout -b‘
function gtag() {
git tag $1;
git push origin $1;
}
# 新添加一条stash条目
$ git stash save ‘test‘
# 或者这样
$ git stash push -m ‘test‘
# 列举所有stash条目
$ git stash list
# 应用指定位置的stash条目
$ git stash apply 0
# 移除指定位置的stash条目
$ git stash drop stash@{0}
# 或者这样
$ git stash apply 0
$ git stash drop 0
# 应用最新的stash条目
$ git stash apply
# 应用并移除最新的stash条目
$ git stash pop
# 清空本地所有stash数据
$ git stash clear
原文:https://www.cnblogs.com/liuhe688/p/14716178.html