[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



I don't really get your problem. Every git repository tracked by remote, has separate refs to track the remote and separate for the local. When you do git fetch, it will only update the remote refs and not your local. Then you can do git diff origin/master to see the difference between your local and remote. Or git log origin/master to see your remote refs history.

Then you can merge or rebase your local with the remote.

Git status however l may tell you that your local is not up-to-date with your remote because it already knows about your remote commits.

On Sep 7, 2014 5:23 AM, "Sven Joachim" <svenjoac@gmx.de> wrote:
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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: [🔎] 87r3znaitn.fsf@turtle.gmx.de" target="_blank">https://lists.debian.org/[🔎] 87r3znaitn.fsf@turtle.gmx.de


Reply to: