git 分支管理

1. 创建分支;

    git branch name   

2. 查看分支;

    git branch 

3. 切换分支;

    git checkout name

4.创建并切换分支;

    git checkout -b name

5.合并分支;

    git merge name

6.删除分支;

    git branch -d name

    git branch -D name 强行删除; 删除没有合并的分支


7. 合并冲突解决;

  手动修改后 add  commit

  使用 $git log --graph --pretty=oneline --abbrev-commit 查看合并情况图

  --graph 图表;

  --abbr-commit   log的缩写;


8. 禁用fast-forward   --no-ff

  由于使用fast-forward 模式,在合并分支并删除分支 后会丢掉删除分支的修改信息;  

  git merge --no-ff -m '合并信息' <branch_name> 


9. $git stash      储存工作现场;

  $git stash list    查看stash;

  恢复现场有两个方法;

    方法1. $git stash apply 恢复后stash内容并没有删除,使用 $git stash drop  删除;

    方法2. $git stash pop 恢复后并删除stash


   可以多次stash;  用$git stash list;查看; 再用$git stash apply stash@{0} 恢复指定的stash;

  

   

    

    

[Power By XIAOWU]
原文地址:https://www.cnblogs.com/webmans/p/8093103.html