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

Git pull without fetch

From
ronan@rjp.ie <ronan@rjp.ie>
Date
Feb 18, 2023, 00:09 UTC
Message-ID
<49c07b5dc2afbd422d492d59380ad2c2@rjp.ie>
Dear maintainers,

I use the git-maintenance prefetch task with a certain repo to periodically fetch updates from the remote. I'm trying to figure out a way to have git "complete" a prefetch on command, via an option, alias, or other extension that mimics the behavior of git pull, but does not fetch from the remote. By comparison, `git pull` or `git fetch && git rebase` would fetch the remote and fast-forward my local copy to match, but I don't want to fetch the remote. Instead I want to fast-forward my current branch (and the remote tracking branch) to the prefetched tip as if git pull had been run at the time of the last prefetch.

For example, suppose my local copy has a branch master that tracks the remote branch master from origin. Suppose that the local copy (and the remote tracking branch) have commits A--B, the remote has commits A--B--C--D, and commit C has been prefetched and is pointed to by refs/prefetch/remotes/origin/master. The desired effect could be accomplished, I think, by:

git update-ref refs/remotes/origin/master refs/prefetch/remotes/origin/master refs/heads/master && git rebase origin/master master

My question is, how can I calculate the correct remote tracking branch to accomplish this operation in the general case, just as git pull without argument would have done? Or is there a simpler way to achieve my goal?

Cheers, Ronan

Next: ronan@rjp.ie
Message 1 of 4 in “Git pull without fetch”
  1. ronan@rjp.ieFeb 18, 2023
  2. ronan@rjp.ieFeb 18, 2023
  3. Junio C HamanoFeb 18, 2023
  4. ronan@rjp.ieFeb 18, 2023

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.