[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



Joel Rees <joel.rees@gmail.com> writes:

> On Sat, Sep 6, 2014 at 7:04 AM, lee <lee@yun.yagibdah.de> wrote:
>> Hi,
>>
>> how would I figure out what the last commit to a remote repo was without
>> first fetching or pulling the remote repo?
>>
>> Assume that I have a local copy, say cloned yesterday.  Today I would
>> like to be informed automatically of new commits without fetching or
>> pulling from the remote repo.  It would suffice to know whether there
>> have been new commits or not.
>>
>>
>> 'git log -1 --date=relative --format=%at' gives me a very useful output
>> for my local instance of the repo, but there doesn't seem to be any way
>> to get this kind of output for the remote repo.  Or is there?
> [...]
>
> The more I think about this, the more I think you are trying to do
> something the hard way.

Hm, I'm trying to do it the easy way.

> Is setting your head and running a diff or status insufficient?

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).

However, if I can take for granted that 'git status' will output "Your
branch and.*have diverged," when new commits have been made to the
remote repo, that would suffice.  But can I take this for granted?

> If so, I'm tending to think you might want two local repositories, one
> to track the remote, and one that you work in.

That is precisely what I'm trying to avoid :)


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.)


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


Reply to: