git建立本地分支以及推送本地分之至遠程分支

Git分支策略javascript

實際開發中,應當按照如下幾個基本原則進行管理:java

首先,master分支應該是很是穩定的,也就是僅用來發布新版本,平時不能再上邊幹活。git

那在哪幹活呢?幹活都在dev分支上,也就是說,dev是不穩定的,到某個時候,好比1.0版本發佈的時候,在將dev分支合併到master,在master分支發佈新版本。github

你和你的小夥伴都有本身的分支,每一個人在本身的分支上幹活,時不時地往dev分支上合併就能夠了。ide

因此團隊合做分之看起來就像這樣:this

 

 

git建立分支並切換到當前新建立的分支上spa

git checkout -b devcode

開發完成後orm

git push origin devxml

此時就將本地分支推送到遠程相應的分支上了

此時,團隊裏另外一個成員要更新遠程dev分支上的代碼

git pull 

若出現以下錯誤

 

$ git pull
remote: Counting objects: 5, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 3 (delta 0) Unpacking objects: 100% (3/3), done. From github.com:michaelliao/learngit fc38031..291bea8 dev -> origin/dev There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream dev origin/<branch>  

 

git pull失敗了,緣由是沒有指定本地dev分支與遠程dev分支的連接。

根據提示設置

 

git branch --set-upstream dev origin/dev

 

此時又出現提示

The--set-upstream flag is deprecated and  will be removed.Consider using --track or --set-upstream-to

Branch dev set up to track remote branch dev from origin.

因而從新設置

 

git branch --set-upstream-to  origin/dev--set-upstream-to

 

而後就直接pull了

git pull

該同事修改完成後,又要將本地分支推送到遠程dev分支

但他習慣性的用了

git push

因而出現了警告

warning:push.default is unset;its implicit  value has changed in Git 2.0 from 'matching' to 'simple' .

根據提示

咱們設置

git config --global push.default simple

以後就能夠直接用

git push

而不用再寫

git push origin dev了