Reputation: 14984
for pushing to bitbucket.
If I do: git push origin origin/branch_name
my commits are not pushed.
Total 0 (delta 0), reused 0 (delta 0)
If I do git push origin branch_name
my commits are pushed:
Counting objects: 160, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (20/20), 2.10 KiB | 0 bytes/s, done.
Total 20 (delta 6), reused 0 (delta 0)
so what is the origin/ mean in front of the branch_name? And why does it matter?
Upvotes: 37
Views: 33763
Reputation: 66183
You have to keep in mind that there are different types of branches:
origin
. From that repository's point of view, though, such a branch is local. Welcome to Distributed Version Control! :)
Here, branch_name
is a local branch, whereas origin/branch_name
is a remote-tracking branch; it reflects the state of the corresponding branch that lives in origin
.
Right after running
git fetch
the remote-tracking branch origin/master
and the corresponding branch that live in origin
should be perfectly in sync (modulo concurrent pushes to the remote server, of course). It shouldn't be a surprise, then, that
git push origin origin/branch_name
doesn't push anything: you're essentially attempting to push stuff that is already present in the ancestry of the corresponding branch that live in origin
.
However, if your local branch, branch_name
, is ahead by one or more commits,
then running
git push origin branch_name
will push the commits contained in branch_name
to origin/branch_name
:
Upvotes: 49
Reputation: 31264
using a graphical tree viewer (like gitk --all
) will show you, that origin/mybranch
and mybranch
might differ.
origin
is just the default name for a cloned remote, which (in your case) contains a branch mybranch
(just like your local repository)
so when you ask to push origin/mybranch
to origin
, you are synchronizing the origin
remote with itself, hence it doesn't do anything (luckily the remote is always in synch with itself).
the name origin
is arbitrary, and could have been set with the --origin
flag when cloning.
Upvotes: 4
Reputation: 10947
origin/branch_name
is a branch on the remote machinebranch_name
is a branch on the local machineUpvotes: 3
Reputation: 619
origin is whats stored remotely on github
without origin is what is stored locally on your computer
when you commit 1st you are commit locally to your computer
when you push origin branch name you are pushing to github
Upvotes: 1