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
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 19, 2008, 16:33 UTC
Message-ID
<20081219163300.GT32487@spearce.org>
In-Reply-To
<494BC89F.9070107@gmail.com>
Ivan Zorin <ivan.a.zorin@gmail.com> wrote:
Show 7 quoted lines
> Hello. I have not very hard question, but I don't know how to better do
> it - could you tell me, please, does exist some way to check remote git
> repository for updates without downloading any essential files? I
> suppose, that such command should just type something like: "already
> updated", if current working tree identical to remote repo, and
> something like "there is some updates in remote repo", if remote repo
> has some new commits and/or branches. Thanks.
There aren't any commands to do it.

What you could do is write a script based upon git ls-remote. A really simple one might be:

	#!/bin/sh
	remote=$1
	o=.git/remote_cache.$remote
	n=$o.new$$
	git ls-remote $remote >$n
	if [ -f $o ]
	then
		if diff $o $n >/dev/null
		then
			echo "No changes"
		else
			mv $n $o
			echo "Updates available"
	else
		mv $n $o
		echo "New remote remembered..."
	fi

A much more complex one would actually rewrite refs/heads/ to the correct refs/remotes/ namespace on your local repository and compare the remote ref values to the local refs/remotes values.

Patches for git fetch --pretend or something might be interesting. Though I recall a thread about this before on the MLand saying there was no point. Its not like you can see how big the download would be until after its over.

-- 
Shawn.
Previous: Ivan ZorinNext: Ivan Zorin
Message 2 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.