[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



"Podrigal, Aron" <aronp@guaranteedplus.com> writes:

> I don't really get your problem.

The problem is very simple: I want to get an email when new commits have
been made to a remote repo which I have cloned (some time in the past).

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

Hm, let's see:


[~/inst/emacs/emacs-git/emacs] git diff origin/master
[some diffs are displayed]
[~/inst/emacs/emacs-git/emacs] git fetch
remote: Counting objects: 136, done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 79 (delta 72), reused 0 (delta 0)
Unpacking objects: 100% (79/79), done.
>From git://git.savannah.gnu.org/emacs
   bf72a39..ed16e32  master     -> origin/master
   bf72a39..ed16e32  trunk      -> origin/trunk
[~/inst/emacs/emacs-git/emacs]  git diff
[~/inst/emacs/emacs-git/emacs] 


Shouldn't there be (even more) diffs displayed /after/ the fetch because
my local copy of the remote repo has content (even more) different from
what's in the remote repo because I haven't even merged yet what was
previously fetched?


And what if I don't want to do 'git fetch'?  Is there a way to undo a
(series of) 'get fetch'?

The 'git fetch' would have to happen automatically from the script which
is supposed to figure out if there have been new commits and to send me
an email.  The script is run via cron.

Having to run a full 'git fetch' would appear to me as a rather drastic
measure I'd have to take just to figure out if there have been new
commits, and what are the potential security risks involved in running
'git fetch' from a script via cron?

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

Well, I'm not making commits to the upstream remote repos, only to
remote repos which are copies of my local ones.  Those remote ones can
only be in sync with or behind my local ones, until I push to them.


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


Reply to: