Simone
Simone

Reputation: 27

apply changes to another branch git

this is my issue: I have 2 branch, master and deploy, I want work on master branch and on finish bring my changes to deploy branch and push it to remote repository. I tried this way:

git branch deploy

now I have 2 branch, first commit on master branch:

git commit -a -m "first commit"

bring the changes to deploy repository:

git merge deploy

go to deploy branch:

git checkout deploy

push the changes:

git push origin deploy

but the merge command does not give me the expected result.

Any advice?

Thanks in advance!

Upvotes: 1

Views: 174

Answers (1)

ErikMD
ErikMD

Reputation: 14723

According to the description of the workflow you put along the Git commands, it seems that you are using git merge in the reverse way.

Indeed, git merge a-given-branch basically means "integrate a-given-branch into the current branch (creating a merge commit if need be)".

Thus, your proposed workflow should read:

git branch deploy

now I have 2 branch, first commit on master branch:

git commit -a -m "first commit"

go to deploy branch and import the changes from master:

git checkout deploy
git merge master

push the changes to deploy repository:

git push origin deploy

For more details on the git merge command, see also the online documentation.

Upvotes: 1

Related Questions