添加仓库
git remote add origin git@github.com:xxx/xxx.git
git remote add 别名 仓库地址
新建分支
git branch <new-branch>
git checkout <new-branch>
git rm --cached -r .
git clean -f -d
git commit --allow-empty -m "[empty] initial commit"
git push origin <new-branch>
查看分支
git branch
git branch -a
删除分支
git branch -d <name>
合并某分支到当前分支
git merge <name>
暂存代码
git add.
本地分支关联远程分支
git checkout -b dev
git pull origin dev
git checkout -b test
git push origin test
git push origin dev:dev
git push origin openclass20190517:openclass20190517
回滚到某个版本
git reset --hard 版本号
git reset HEAD~
// 将本地强制同步远程仓库(git fetch)
git push origin feature-xxx --force
取消暂存区的文件
git reset HEAD src // 取消已经add的文件夹src
查看配置
git config
设置用户名邮箱
git config user.name 'xxx'
git config user.email 'xxx'
拉取所有远程分支【mac】
git branch -r | grep -v '->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
// 抓取远程所有分支的变动
git fetch --all
// 拉取远程所有分支的变动并合并文件
git pull --all
新建标签
用于新建一个标签
git tag <tagname>
指定标签信息
git tag -a <tagname> -m "xxxx"
查看所有标签
git tag
区分文件大小写
git config core.ignorecase false