GIT常用命令-分支管理
Posted cjxltd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GIT常用命令-分支管理相关的知识,希望对你有一定的参考价值。
分支管理的好处:既不影响别人的工作又无需承担文件进度丢失的风险






1.创建与合并冲突



$ git checkout -b dev
相当于
$ git branch dev
$ git checkout dev
$ git branch
查看分支
$ git checkout master
切换分支
$ git merge dev
$ git branch -d dev
删除分支
2.解决冲突

Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.
<<<<<<< HEAD
Creating a new branch is quick & simple.
=======
Creating a new branch is quick AND simple.
>>>>>>> feature1
解决冲突后继续提交
$ git log --graph --pretty=oneline --abbrev-commit
3. 分支管理策略
$ git merge --no-ff -m "merge with no-ff" dev


4 bug分支
$ git stash
用于把当前现场存储起来 等一会恢复继续工作
$ git stash list
显示stash存放的地方
git stash apply
git stash drop
恢复stash 删除stash
git stash pop
恢复同时把stash也删除了
$ git stash apply stash@{0}
多次stash之后恢复指定的stash
5 feature分支
$ git branch -D feature-vulcan
在创建了提交了分支之后,想不合并分支直接删除分支,需要大写的D来删除分支
6 多人协作
$ git pull
更新分支
$ git branch --set-upstream dev origin/dev
合并远程和本地分支
$ git remote -v
以上是关于GIT常用命令-分支管理的主要内容,如果未能解决你的问题,请参考以下文章
源代码管理相关命令(Git常用命令Nuget常用命令CMD常用命令)