1 分支命令
序号 | 参数 | 描述 |
---|---|---|
1 | git branch | 查看分支 |
2 | git branch name | 新建分支,其中name为分支名称 |
3 | git checkout name | 切换到name分支 |
4 | git merge name | 合并name分支到当前分支 |
5 | git branch -d name | 删除name分支 |
6 | git push -u name:name1 | 提交分支name到云端分支name1 |
7 | git log | 查看commit日志 |
2 分支提交流程
【说明】
第五步:提交本地分支到云端,格式:
git push -u origin 本地分支名称:云端分支名称
若云端分支与本地分支相同,则可忽略云端分支名称,如下:
git push -u origin 本地分支名称
第七步:合并分支:
若使用本地的分支名称合并,格式如下:
git merge branch_name
若使用云端分支合并,格式如下:
git meger origin/cloud_branch_name
第八步:云端合并
主分支下找到:Compare&pull request
↦
\mapsto
↦Creat pull request
↦
\mapsto
↦Merge pull request
↦
\mapsto
↦Confirm merge.
3 分支提交命令
1.提交文件至缓存:git add file/folder
2.提交文件至版本库:git commit -m "description"
3.本地新建分支:branch_name:git branch branch_name
4.切换到新建分支:git checkout branch_name
5.提交本地分支到云端:git push -u origin branch_name:cloud_branch_name
6.切换到主分支: git checkout master
7.合并分支:
git merge branch_name
git meger origin/cloud_branch_name
4 提示
- 切换分支
git checkout subBranch
- 提交分支
git push -u origin subBranch
- 合并分支
切换到主分支
git checkout master
合并
git merge subBranch
远程同步
git push -u origin master
- 删除分支
删除本地分支
git checkout master
git branch -r -D origin/subBranch
删除远程分支
git push origin -d subBranch
【参考文献】
[1]https://www.cnblogs.com/fqlife/p/8493745.html
[2]https://blog.csdn.net/qq_27437967/article/details/71189571
[3]https://www.cnblogs.com/wild-programmer/p/6241978.html
[4]https://www.jianshu.com/p/664bb86a11e2
[5]https://git-scm.com/book/zh/v1/Git-%E5%88%86%E6%94%AF
[6]https://www.cnblogs.com/VAllen/p/git-remote-delete-origin-branches.html