Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push from one branch to another and checkout?

Tags:

git

I am trying to implement the setup outlined here http://toroid.org/ams/git-website-howto but with one difference. On my local repository I want to use a branch different to master.

So when I go to push the initial files rather than push the master files I want to push the files from my demo branch to the master branch on the remote repository. For example:

git push web +master:refs/heads/demo 

But when I do this I get the following error after it completes uploading all of the files:

remote: fatal: You are on a branch yet to be born 

Is it possible to do what I am trying to do with this setup?

like image 256
startupsmith Avatar asked Dec 18 '11 08:12

startupsmith


People also ask

How do I push one branch to another branch?

Push Branch to Another Branch In some cases, you may want to push your changes to another branch on the remote repository. In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.


1 Answers

If the local branch is called "demo" and you want to push to branch called "master" on the remote called "web", then do the following:

git push web demo:master 

If you want to merge from the "master" branch on the remote "web" into your current branch, you can do the following:

git fetch web git merge web/master 
like image 135
David M. Syzdek Avatar answered Oct 06 '22 08:10

David M. Syzdek