From a git branch, a colleague of mine ran
git diff origin master
What is it supposed supposed to do? What does origin
separately point to?
This is related, but not covered in In Git, what is the difference between origin/master vs origin master?
It shows the changes between the tips of origin/HEAD and the master branches. You can achieve the same with following commands: git diff origin/HEAD master. git diff origin/HEAD..
The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch.
Master: This is a branch name where we first initiate git and then we use to make commits. And the changes in the master can pull/push into a remote. origin/master: This is a remote branch, which has a local branch named master on a remote named origin.
Diff command is used in git to track the difference between the changes made on a file. Since Git is a version control system, tracking changes are something very vital to it. Diff command takes two inputs and reflects the differences between them. It is not necessary that these inputs are files only.
This form of git diff
just takes two revision specifiers, as described in gitrevisions.
In this case origin
is most likely to match item 6:
- otherwise,
refs/remotes/<refname>/HEAD
if it exists.
So this means the same as git diff origin/HEAD master
: resolve origin/HEAD
to a commit-ID, resolve master
to a commit-ID, and diff the two commits.
Run:
git rev-parse origin
to see how the resolution works.
"origin" points to the "remote", typically where you cloned the repository from, see
$ git remote -v show
But specifically in answer to your question "git diff origin master" is equiv. to this:
$ git diff origin/HEAD master
origin/HEAD to the branch pointed to by HEAD reference on the remote. Which was the checked out branch at last pull.
Take a look at your commit graph, which will show you where all your references are (--decorate)
$ git log --oneline --graph --all --decorate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With