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

I want "fast forward my workdir to upstream if it's safe"

From
Randal L. Schwartz <merlyn@stonehenge.com>
Date
May 7, 2009, 21:40 UTC
Message-ID
<86prekfv7z.fsf@blue.stonehenge.com>

For the past few years, within any given 12 hour period, at least one person on #git would come up with the use case with which I'm really familiar (having needed it many times myself):

  I have a workdir tracking a remote.
  I may or may not have made local edits... I can't remember.
  I may or may not have made local commits... I can't remember.
  But the upstream might now have changed... please update me *safely*.

Seriously, this comes up, a lot. Typically, from a cron job updater, but often just "what can I do to make sure I'm up to date".

So, what I need is a command, likely an option to "git merge" that says "do everything that a git merge would do except abort if it would have been a merge commit". In other words, abort if the workdir is dirty or is not a fast-forward update to the upstream. Bonus if it exits non-zero if something went wrong.

Please don't tell me "use these three commands in this script". I want a *command* I can tell people in #git.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Next: Wincent Colaiuta
Message 1 of 12 in “I want "fast forward my workdir to upstream if it's safe"”
  1. Randal L. SchwartzMay 7, 2009
  2. Wincent ColaiutaMay 7, 2009
  3. Randal L. SchwartzMay 7, 2009
  4. Jeff KingMay 8, 2009
  5. Andreas EricssonMay 8, 2009
  6. Jeff KingMay 8, 2009
  7. Eyvind BernhardsenMay 8, 2009
  8. Randal L. SchwartzMay 8, 2009
  9. Junio C HamanoMay 8, 2009
  10. Jakub NarebskiMay 8, 2009
  11. Eyvind BernhardsenMay 11, 2009
  12. Miles BaderMay 8, 2009

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.