假如我是master
分支並創建一個新的分支:Git:什麼是將工作分支合併到主的最快方法?
git checkout -b feature_branch
我開始對feature_branch
工作,並在某些時候,我想用變基到我的變化合並master
。所以,我這樣做:
# Get the latest code on master
git checkout master
git pull
# Rebase on master and push the most updated 'feature_branch'
git checkout feature_branch
git rebase master
git push
# Merge 'feature_branch' to 'master' and push the updated 'master'
git checkout master
git merge feature_branch
git push
# Back to work on 'feature_branch'
git checkout feature_branch
有沒有辦法減少步驟數量並達到相同?
在過程結束時,我希望master
,origin/master
,feature_branch
和origin/feature_branch
指向相同的提交。
好的答案!風格的東西,但也許「git pull。feature_branch」,而不是「git merge feature_branch」。加入git push也可能很酷--tags – 2012-02-11 03:34:13
@AdrianCornish:'git pull。 feature_branch'會和'git merge feature_branch'完全一樣,只會更容易混淆。我在這裏沒有看到任何東西來表明標籤需要處理。 – Cascabel 2012-02-11 03:37:57
同意 - 標籤可能是一個額外的功能:-)。 同意這兩個命令是相同的,我之所以建議這樣做,是因爲拉請求工作流被用於許多OpenSource的東西 - 因此實際上您正在響應您寫的拉請求。純粹是一種精神狀態 - 你將Repo Y中作者X的改變拉到你的分支Z. – 2012-02-11 03:53:43