Pushing code from one branch of a repo to another branch of another repo
The answer by Roman is correct. However, there is an additional step that might not be obvious for some. You will need to first add the remote name and URL of the new repo(Repo you are trying to push to), before pushing to a branch in that repo. This can be done like so;
git remote add <remote name> <remote url>
//For example
git remote add origin2 https://[email protected]/example/new_repo.git
Then you can proceed like in Roman's answer, by pushing to that new repo branch like so
git push origin2 local_branch:new_repo_branch
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