3

I have a local branch which is a new branch called A.

I want to push it to the remote, but I want it to be named differently in the remote.

For example, remote name would be users/me/A but in local, it would still be called A

How can I do that?

MarkD
  • 482
  • 2
  • 6
user482594
  • 16,878
  • 21
  • 72
  • 108

3 Answers3

11

This should do it:
git push remoteRepo localBranchName:desiredName

Here is some more info on the process

Community
  • 1
  • 1
Andy
  • 44,610
  • 13
  • 70
  • 69
3

You can push a local branch A to a remote branch B using this command:

git push -u origin A:refs/heads/B

-u flag will let you not specify the name of the remote branch in future.

Roman Cheplyaka
  • 37,738
  • 7
  • 72
  • 121
1
git branch --set-upstream a origin/me/a

will set it permanently, so you don't have to specify the remote with every pull. Add

[push] default=tracking

to your .git/config so that pushes go the same places pulls come from.

Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51