1. 拉取子模块
git clone 仓库地址
git submodule update --init --recursive
或:
git clone --recursive 仓库地址
2. 相关信息查看
查看远程仓库地址:
git remote -v
查看本地分支所跟踪的远程分支:
git branch -vv
查看用户名和邮箱:
git config user.name
git config user.email
修改用户名和邮箱:
git config --global user.name "NewUserName"
git config --global user.email "NewEmail"
3. 删除本地/远程分支:
git branch -d <BranchName> (强删)
git push origin --delete <BranchName>
4. 放弃本地未提交的修改:
git checkout
5. 强制同步远程仓库:
git fetch --all
git reset --hard
6. git rebase
用于把一个分支的修改合并到当前分支
git rebase dev
7. 强推远程
git push --force-with-lease
8. git commit Angular 规范
<type>(<scope>): <subject>
type:用于说明本commit的类别,feat(新增)、fix(修复)、docs(文档操作)、style(代码风格)、refactor(代码重构)、test(增加测试)、chore(其他变动)等
scope: commit影响的范围
subject:描述信息
9. 压缩合并多次提交
git rebase -i [startpoint] [endpoint]
前开后闭,不指定endpoint则默认终点是当前HEAD指向的commit
10. 设置本地分支关联远程分支
git branch --set--upstream-to=origin/分支名 分支名