1. 程式人生 > >GIT常用命令-分支管理

GIT常用命令-分支管理

分支管理 ash 9.png initial tin creating 多次 set stream

分支管理的好處:既不影響別人的工作又無需承擔文件進度丟失的風險

1.創建與合並沖突


技術分享
技術分享
技術分享
  1. $ git checkout -b dev
相當於
  1. $ git branch dev
  2. $ git checkout dev
  1. $ git branch
查看分支
  1. $ git checkout master
切換分支
  1. $ git merge dev

  1. $ git branch -d dev

刪除分支

2.解決沖突

技術分享
  1. Git is a distributed version control system.
  2. Git is free software distributed under the GPL.
  3. Git has a mutable index called stage
    .
  4. Git tracks changes of files.
  5. <<<<<<< HEAD
  6. Creating a new branch is quick & simple.
  7. =======
  8. Creating a new branch is quick AND simple.
  9. >>>>>>> feature1
解決沖突後繼續提交
  1. $ git log --graph --pretty=oneline --abbrev-commit

3. 分支管理策略

$ git merge --no-ff -m "merge with no-ff"
dev

技術分享
技術分享

4 bug分支

  1. $ git stash
用於把當前現場存儲起來 等一會恢復繼續工作
  1. $ git stash list
顯示stash存放的地方
  1. git stash apply
  1. git stash drop
恢復stash 刪除stash
  1. git stash pop
恢復同時把stash也刪除了
  1. $ git stash apply stash@{0}
多次stash之後恢復指定的stash

5 feature分支

  1. $ git branch -D feature-vulcan
在創建了提交了分支之後,想不合並分支直接刪除分支,需要大寫的D來刪除分支

6 多人協作

  1. $ git pull
更新分支
  1. $ git branch --set
    -upstream dev origin/dev
合並遠程和本地分支
  1. $ git remote -v



GIT常用命令-分支管理