![](/img/trans.png)
[英]<GIT> I have branched off a branch and want to push my changes. Do I push changes to the original branch or merge the two branches?
[英]Git: Change branch I have branched off of
對於一項新功能,我從當前的dev分支(不是master)在Git中創建了一個分支,並在本地實現了一些更改,但未提交。 然后我被束縛了,開發繼續進行。 我用作基礎的分支現已關閉,並且有一個新分支。
如何更改功能分支,使其以新的dev分支為基礎?
master --
\-- dev 1
\-- feature
\-- dev 2
現在我想移動功能,因為它分支到了dev 2,然后提交了我的更改:
master ---
\-- dev 1
\-- dev 2
\-- feature
當然,在不丟失其他人可能做出的提交的情況下,也可以將其添加到功能分支。
你需要
git rebase dev1 feature --onto dev2
(如果我沒記錯的話,您可能需要dev1^
但我不相信)。
看起來您必須在dev2
分支的頂部添加尚未提交的dev2
。 如果我弄錯了,請糾正我。
git stash save -u "My feature" # stash all changes
git branch -d feature # delete old feature branch
git checkout dev2
git branch -b feature # create new feature branch
git stash apply # unstash all you changes
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.