Difference between git push origin prod AND git push origin prod:refs/heads/prod

When I create a new branch and then want to push it remotely, I can do:

git push origin prod

OR

git push origin prod:refs/heads/prod

What is the difference ?

  • Can I pull only certain files from another git repository?
  • Why can I checkout a deleted Git branch, and why is it still available on GitHub?
  • How to keep .gitignored files off my gh-pages branch?
  • How to determine the author of a branch in git
  • How to find all refs that contain a commit in their history in git
  • Git tag release version?
  • Git branch not returning any results
  • Remove all local closed branch depends on its remote status
  • One Solution collect form web for “Difference between git push origin prod AND git push origin prod:refs/heads/prod”

    On vanilla configurations, there would be no difference.

    However, remotes can be configured with custom push branch specifications in .git/config. In that case, specifying the explicit ref name on the server end like local_ref_name:remote_ref_name overrides the configured mappings.

    If you had just added a new remote, and wanted to push for the first time, you would need to at least specify the branch to push. In that case

    git push origin prod
    git push origin prod:prod
    git push origin prod:refs/heads/prod
    

    would all have been equivalent. Final trivia:

    git push origin :prod
    

    will delete the ref named prod on the remote end.

    Git Baby is a git and github fan, let's start git clone.