2017-06-14 73 views
0

讓我們說,我們現有的分支命名如果我從現有分支中分支,哪個分支將獲得我推送的代碼?

stable-branch 

然後我從該分支支由

git checkout -b mybranch stable-branch 

我coding..if我

git commit -m "blah blah blah" 

,然後完成後

git push origin mybranch 

將穩定分支遠程倉庫會受到影響後,我把它推到我自己的分支?

+0

不,既然你指定推到'產地/ mybranch'。你需要推動'stable-branch'來影響它的遠程回購。 –

+0

你是第一個回答的人。公平起見。如果您希望您的答案被接受,請將您的答案輸入正確的輸入框。謝謝 – sasori

+0

簡單的是/否回答一般不需要正式答案,所以不用擔心。 –

回答

0

編號 您的代碼/提交可以在mybranch中看到,也可以在遠程看到

而最好的方法是:

git fetch origin // (or your repo name) 
git checkout -b myNewBranch 
git reset --hard origin/stable-branch 
Do changes 
git status // to see changed files 
git commit -am "commit message here" 
git branch // to see branches in your local repo 
git log --oneline -20 // to see your new commit in the list 
git fetch origin // Fetch again (to get new commits if any) 
git rebase origin/stable-branch // Rebase again to make sure your's is the latest one 
git push origin myNewBranch 

在這裏你沒有檢出你穩定的分支,如果你沒有在它的任何變化。

0

包含兩個分支都將受到影響,從現在起的存儲庫包含您的分支mybranch推變化。但是:stable-branch將不會看到任何更改。這是分支的概念。

mybranch工作,你提交併推送隨意並因此能夠與你的團隊在您正在開發的功能進行協作。通過推送本地特性分支變得遠程且對存儲庫中的所有其他開發人員可見。穩定版本分支保持不變(它必須這樣做,否則你將一直在潛在生產分支上開發)。

stable-branch將盡快爲您合併mybranch到它,並在過程之後推像

git checkout mybranch 
git commit -m "stuff" 
git push -u origin mybranch //optional publishing 
git checkout stable-branch 
git merge mybranch //now affecting stable-branch for the first time 
//optionally solve occurring merge-conflicts now 
git push -u origin stable-branch 

如果合併之前單獨工作的所有出版的影響是可選的,但建議作爲這個遠程跟蹤您的版本歷史記錄(基本上Git是做什麼的),所以允許回滾,rebase和在不同的機器上工作。

參見here進行了詳細的說明書。

相關問題