git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to check remote git repo for updates without pull/fetch

From
Boyd Stephen Smith Jr. <bss@iguanasuicide.net>
Date
Dec 21, 2008, 00:02 UTC
Message-ID
<200812201802.57953.bss@iguanasuicide.net>
In-Reply-To
<402731c90812201541r510170tbe1d56b7261e8146@mail.gmail.com>
On Saturday 2008 December 20 17:41:13 David Aguilar wrote:
Show 19 quoted lines
> 2008/12/20 James Cloos <cloos@jhcloos.com>:
> > #!/bin/bash
> > #
> > # does this git repo need a pull?
> > #
> > l=$(git log|head -1|awk '{print $NF}')
> > r=$(git ls-remote origin heads/master|awk '{print $1}')
> > test "${r}" != "${l}"
> >
> >
> > -JimC
> > --
> > James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6
>
> Hello
>
> Your script will report false positives if you run that in a branch
> where you've made local commits since git log's output will list a
> commit that's not on the remote side.

Change the last line to: test "${r}" != "$(git merge-base "${r}" "${l}")" and those false positives should go away.

The script is far from a complete solution to the OPs problem though. It only checks one, specific remote branch. It only checks against the current branch. It is the core of something that might be useful as another subcommand to 'git remote' though.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
Previous: David AguilarNext: James Cloos
Message 6 of 7 in “how to check remote git repo for updates without pull/fetch”
  1. Ivan ZorinDec 19, 2008
  2. Shawn O. PearceDec 19, 2008
  3. Ivan ZorinDec 19, 2008
  4. James CloosDec 20, 2008
  5. David AguilarDec 20, 2008
  6. Boyd Stephen Smith Jr.Dec 21, 2008
  7. James CloosDec 21, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.