0

I created a new local Branch and trying to push the code to a new remote branch. When the local and remote branch names differ, the code isn't getting pushed. But when the names are same, code is getting pushed. Is this behavior normal or am I missing anything? Thanks in advance.

enter image description here

METALHEAD
  • 2,734
  • 3
  • 22
  • 37

1 Answers1

1

For a basic complete push command, it's like

git push <remote> <local_revision>:<remote_ref>

<local_revision>:<remote_ref> is a refspec.

For example, to push the 2nd parent of the commit abc123 to create a new ref refs/sandbox/foo,

git push origin abc123^2:refs/sandbox/foo 

To push the local master to the remote (origin in this case) master,

git push origin refs/heads/master:refs/heads/master

When master is indeed a branch, we can omit the refs/heads/ part if no naming conflicts,

git push origin master:master

When the local branch and the target branch are both named master, we can omit the target branch name,

git push origin master

With the help of some configuration variables, we can shorten the command further. When the current branch is master and in git config branch.master.remote=origin and remote.origin.push=refs/heads/*:refs/heads/* are set, we can simply run git push.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53