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

RFC: git sync

From
Larry D'Anna <larry@elder-gods.org>
Date
Feb 10, 2010, 03:27 UTC
Message-ID
<20100210032720.GA5205@cthulhu>

So say you have a project with a bunch of branches. You have two main computers you work on: a laptop and a workstation, and you keep an authoritative copy on a server somewhere. When you sit down at your laptop to work on your project, the first thing you want to do is make sure that whatever you've got locally is up-to-date with the repo on the server. So you run:

git push origin :

Then if it says anything isn't a fast-forward, you use some combination of git pull, git checkout, or git fetch to get all you branches up to date, then possibly you run the push again to push merges back to the server.

How about instead we add a new command called "git sync" that does all that for you? So if you say

git sync origin : 

It matches refs just like git-push would, but it will also automatically fast-forward your local refs if possible. (and update the worktree+index if HEAD is one of the local refs that gets fast forwarded). If any merges would be required, it will print a warning and leave that ref alone.

And if you say
git sync --merge origin :

it will try to merge any refs that need it. If the merge succeeds, it will be exactly as if you had said

git checkout foobranch git pull origin foobranch git push origin foobranch

What do you all think? If you like the idea, I'll do it as a builtin. Otherwise I'll just hack up a perl script for myself.

          --larry
Next: Jakub Narebski
Message 1 of 4 in “RFC: git sync”
  1. Larry D'AnnaFeb 10, 2010
  2. Jakub NarebskiFeb 10, 2010
  3. SergioFeb 10, 2010
  4. Larry D'AnnaFeb 10, 2010

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.