Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing code from one branch of a repo to another branch of another repo

There is a repo say ABC/A. I had forked this repo to my own github say ME/A. I was asked to create a branch on ME/A say x (originally there were develop and master). I had to write some code, so I cloned ABC/A and worked on its develop branch. But now when I have to push the code, I cannot push it to ABC/A as i dont have rights to do so. I have to push the code to ME/A. The problem is, I worked on develop branch for ABC/A but I have to push the code to ME/A x branch. Is it possible to push code in such a way?

like image 831
user3119346 Avatar asked Mar 11 '16 11:03

user3119346


People also ask

How do I push a branch from one repo to another?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.


1 Answers

Yes, you can push any local branch to any remote branch. The syntax is

git push <remote name, e.g. origin> <local branch name>:<remote branch name> 

If your current branch (the one you want to push) is called develop, the command would be

git push ME develop:x 
like image 76
Roman Avatar answered Sep 20 '22 22:09

Roman