Git将master分支合并到其他分支中

时间:2017-03-22 14:18:00

标签: git laravel-5

我有一个主分支,我的主应用程序是。

我正在使用主应用程序顶部的网上商店模块扩展应用程序。

当我对主应用程序进行更改时,我希望它们也可以在webshop-app中使用?

当我现在做git checkout网上商店时,我对主人所做的更改将丢失,我必须将它们复制到网上商店。

我现在做什么:

git checkout master
git add .
git commit -m "changes made to master application"
git push origin master

git checkout webshop
// copy and paste my changes here
git add .
git commit -m "Changes also made here"
git push origin webshop

我试过了:

git push origin master webshop

但这只是推动我在atm的分支中的提交

2 个答案:

答案 0 :(得分:2)

这应该可以解决问题:

git checkout webshop
git merge master

答案 1 :(得分:0)

你可以(应该)一次只提交一个git分支。

想要对多个分支机构进行更改,对我说,你要么误解了GIT的预期工作流程,要么就是试图将它变成一个不是为其设计的用例。

您应该一次只需要/想要将更改提交到一个分支。然后,如果/当您希望这些更改出现在另一个分支中时,请将其合并。

$ git checkout webshop
... make changes as needed, test, etc
$ git add .
$ git commit -m "some changes are made"
$ git push origin webshop

... then, when your'e ready to merge into your main branch (as said by @vasekhlav)
$ git checkout master
$ git merge origin/webshop
... all changes made in webshop will now be in master, providing there were no conflicts that need to be resolved.

之后,再次结帐网站,继续。