1

I have a master branch where my master-app is.

I am expanding the app with a webshop module on top of the master-app.

When i do changes to the master app, i want them to also be in the webshop-app?

When i now do git checkout webshop, the changes i made to master are lost, and i have to copy past them into webshop.

What i do now:

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

I tried this:

git push origin master webshop

But this is only pushing for the commit in the branch i am in atm

munyengm
  • 15,029
  • 4
  • 24
  • 34
Rubberduck1337106092
  • 1,294
  • 5
  • 21
  • 38
  • 2
    Possible duplicate of [Git merge master into feature branch](http://stackoverflow.com/questions/16955980/git-merge-master-into-feature-branch) – Dezza Mar 22 '17 at 14:19

2 Answers2

3

This should do the trick:

git checkout webshop
git merge master
vasekhlav
  • 419
  • 4
  • 12
0

you can (should) only commit to one git branch at a time.

Wanting to commit changes to more than one branch says to me that your'e either misunderstanding GIT's intended workflow, or your'e trying to bend it to a use case that its not designed for.

You should only need/want to commit changes to one branch at a time. Then if/when you want those changes to be present in another branch, merge it.

$ 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.

After that, you checkout webshop again, and carry on.

DevDonkey
  • 4,835
  • 2
  • 27
  • 41