[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: git: how to figure out with a script what the last commit on remote repo is without fetching it



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.

Does this mean that I cannot rely on any of the output of 'git status'
to decide whether there were commits or not?

>> I'd find it hard to believe that there is no reasonable way to check for
>> new commits that have been made to a remote repo.  Git can't be that
>> bad, can it?  (Running 'git diff' for this is not reasonable, and
>> keeping multiple copies of repos isn't, either.)
>
> 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.

The output of 'git status' still seems to be the same, though.


-- 
Knowledge is volatile and fluid.  Software is power.


Reply to: