Git push branch to a new repo with a different name

How can I push a branch to another repo with a new name for the branch.

For example, I have a feature1 branch on repo abc , and I would like to click on repo xyz and make it the main branch.

I tried to rename the remote git branch , but after executing the git clone in the new repo, I got an error

git Warning: remote HEAD refers to non-existent ref, unable to verify

Is there a way to specify in push what I want the name of the destination branch to be?

+6
source share
1 answer

I think this should work:

 git push xyz feature1:master 

If the wizard already exists, you can hide it with -f/--force or + :

 git push -f xyz feature1:master git push xyz +feature1:master 

On the man page (in the examples section at the end):

  git push origin +dev:master Update the origin repository's master branch with the dev branch, allowing non-fast-forward updates. [...] 
+15
source

Source: https://habr.com/ru/post/954984/


All Articles