Re: git: how to figure out with a script what the last commit on remote repo is without fetching it
On 2014-09-07 02:01 +0200, lee wrote:
> Sven Joachim <svenjoac@gmx.de> writes:
>
>> On 2014-09-06 16:42 +0200, lee wrote:
>>
>>> When I run 'git diff', I don't get any output unless I have made local
>>> changes which aren't committed yet. I'm not sure about 'git status':
>>>
>>>
>>> [~/inst/emacs/emacs-git/emacs] git status
>>> On branch master
>>> Your branch and 'origin/master' have diverged,
>>> and have 9 and 51 different commits each, respectively.
>>> (use "git pull" to merge the remote branch into yours)
>>>
>>> Untracked files:
>>> [...]
>>>
>>>
>>> I have not made 9 commits to my local copy, so this is a confusing
>>> message (but IIRC I did run 'git fetch' earlier to see if I could get
>>> any useful info).
>>
>> Even if you have not made any local changes, such things happen if the
>> remote branch has been rebased.
That being said, the branches in the Emacs git repository on Savannah
don't get rebased AFAIK.
> Does this mean that I cannot rely on any of the output of 'git status'
> to decide whether there were commits or not?
Commits where, on your local branch or on the remote one?
>> How about "git fetch --dry-run"?
>
> That doesn't seem to do a dry run:
>
>
> [~/inst/emacs/emacs-git/emacs] git fetch --dry-run
> remote: Counting objects: 35, done.
> remote: Compressing objects: 100% (19/19), done.
> remote: Total 19 (delta 17), reused 0 (delta 0)
> Unpacking objects: 100% (19/19), done.
>>From git://git.savannah.gnu.org/emacs
> bf72a39..b64cc38 master -> origin/master
> bf72a39..b64cc38 trunk -> origin/trunk
> [~/inst/emacs/emacs-git/emacs] git fetch --dry-run
>>From git://git.savannah.gnu.org/emacs
> bf72a39..b64cc38 master -> origin/master
> bf72a39..b64cc38 trunk -> origin/trunk
> [~/inst/emacs/emacs-git/emacs]
>
>
> The first run compresses and unpacks some objects while the second one
> immediately after the first one does not. This must mean that something
> did change by performing a dry run.
Correct, contrary to what the manpage says "git fetch --dry-run" still
downloads a pack file with the objects. It just does not update any
refs.
Cheers,
Sven
Reply to: