记录一下平时的常用命令吧
身份
- 设置username和email
git config --global user.name "anqila"
git config --global user.email "123@gamil.com"
仓库
- 删除与远程仓库的链接
git remote rm origin
- 添加远程仓库地址
git remote add origin 地址
分支
- 删除本地分支
git branch -d test
- 删除远程分支
git push origin --delete 分支名
- 修改本地分支名称
git branch -m oldname newname
- 提交本地分支到远程分支(不同名)
git push origin 本地分支名:远程分支名
- 合并分支
git merge test
或
git rebase test
和远程master分支合并:
git pull origin master
版本
- 回退到上一次commit
git reset --hard
- 回退到某一特定版本
git reset --hard 版本号