0
git push origin local-branch 

What does "origin" mean here? assuming that no upstream is set for my current branch "local-branch". In my perspective, "git push remote-branch" should do the job, since git should understand that i want to push the currently checked branch i.e "local-branch" to "remote-branch". So, in essence, we just need "remote-branch" as an argument to "push" command.

Haris Muzaffar
  • 404
  • 6
  • 17
  • Possible duplicate of [What does origin mean in git, and what do I misunderstand?](https://stackoverflow.com/questions/28045857/what-does-origin-mean-in-git-and-what-do-i-misunderstand) – phd Dec 07 '18 at 14:03
  • https://stackoverflow.com/questions/20889346/what-does-git-remote-mean – phd Dec 07 '18 at 14:03
  • https://stackoverflow.com/search?q=%5Bgit%5D+what+does+origin+mean – phd Dec 07 '18 at 14:03
  • Besides the linked questions and larsks' answer, note that if you want to ask the other Git (at the URL stored under the remote name `origin`) to set *its* branch `world` when pushing *your* branch `hello`, you would write: `git push origin hello:world`. The `hello:world` thing here is a *refspec*, two names separated by a colon, with your local branch name on one side, and the other Git's branch name on the other side. – torek Dec 07 '18 at 16:23
  • With only one name—`git push origin hello`—the missing colon and second name tells `git push` "we use the same branch names", more or less. (It's more complicated in some weird situations, which you should avoid if possible and they won't come up unless / until you start looking for trouble. :-) ) – torek Dec 07 '18 at 16:24

1 Answers1

1

What does "origin" mean here?

That refers to a remote in your local repository. A remote is a label for a remote repository, and is created either implicitly when you run git clone or explicitly when you run git remote add.

A repository can have multiple remotes (for example, you will often have a remote referring to the upstream version of some code and another referring to your own remote fork of that repository).

In my perspective, "git push remote-branch" should do the job, since git should understand that i want to push the currently checked branch i.e "local-branch" to "remote-branch".

If you haven't previously set up tracking information (either implicitly, by checking out a remote branch locally, or explicitly, using git push -u ...), then you need to tell git where to push your branch.

When you git push origin local-branch, you are telling git to push your local branch named local-branch to a remote branch of the same name hosted at origin.

larsks
  • 277,717
  • 41
  • 399
  • 399