1

Sorry if this was answered somewhere else. I've looked at several threads, but to no avail :(

Simple question. We have a remote master branch. A Dev has committed several changes to that remote master branch. I need to apply those to a local branch (the QA server, actually; no dev here), but before doing that, I want git to tell me which commits are pending.

I've tried several combinations of "git diff", using the results from "git branch -a", but nothing came back. Always empty.

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/respaldo
$
$ git diff HEAD master
$ git diff HEAD origin/master
$ git diff master origin/master
$ git diff master remotes/origin/master
$ git log origin/master..HEAD
$ git diff origin/master..HEAD
$

What am I doing wrong?

Thanks a lot!

Leo Lagos
  • 45
  • 7
  • 3
    Did you fetch first? – Biffen Jan 26 '21 at 16:16
  • No. I don't want to do any changes yet. I understand "fetch" will change something locally... right? Is there any "read-only" way of telling this? – Leo Lagos Jan 26 '21 at 16:18
  • 3
    Remember that just because you try to compare with `origin/master` doesn't mean it actually compare with the remote branch on git server. It only checks the local copy of remote branch. So make sure to fetch first – rootkonda Jan 26 '21 at 16:18
  • 1
    fetch isn't going to change anything except fetching the new commits – rootkonda Jan 26 '21 at 16:19
  • 1
    There's no such thing as a *pending* commit, in Git. You must run `git fetch` to obtain the actual commit(s). Once you have the commits, you can inspect them. Until then, you don't have them and cannot inspect them. Having a commit in your repository does not affect your own branches and checkouts: it just adds commits to the repository database, so that you can access them. – torek Jan 26 '21 at 23:37

1 Answers1

2

What am I doing wrong?

Almost all Git operations work on your local information. It looks like your master branch and your origin/master one point to the same commit. You probably need to fetch the changes first.

I don't want to do any changes yet. I understand "fetch" will change something locally... right? Is there any "read-only" way of telling this?

Yes and no. fetch will not change your local master branch. What it will do is download the updates that happened to origin/master, that is, your local copy of the remote branch. So, in a way, there will be changes, but not to master which is supposedly what you care about.

Git doesn't work like SVN or CVS where they are all the time contacting the server (because they don't have the information locally). Instead, you fetch changes whenever you need, and then everything else is local without involving any network calls.

Acorn
  • 24,970
  • 5
  • 40
  • 69