Search code examples
gitgit-remote

git, create remote branch in the same place as another remote


How can I create a remote branch based on another already existing remote without checking out to creating local and pushing to the remote.

To elaborate a little, at repo1 I am at branchA. There exist an origin/branchB and I want to create a origin/branchC in the same place as B. A is different from both. I know B is a duplicate to C in repo1 but at another repo2 eg, it will be different.

(I know the question sounds weird but in my large company environment the production build needs to have a single branch name, but checking all repos is impossible due to space limitations. )


Solution

  • Here is one way to create a remote branchC, which starts on the same commit as origin/branchB :

    git push origin origin/branchB:branchC