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

How to pre-empt git pull merge error?

From
PFPete Forman <petef4+usenet@gmail.com>
Date
Nov 27, 2013, 15:17 UTC
Message-ID
<86d2llc1rs.fsf@gmail.com>

I am looking for a way of detecting up front whether a git pull or git merge would fail. The sort of script I want to perform is to update a server.

    git fetch
    git okay
    stop server
    backup data
    git merge
    start server
Here git okay is a place holder for the command I am asking for.

If a file has been changed outside of a commit then git pull fails with the following error.

error: Your local changes to '...' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.

I would like git okay to perform the pre-merge checks described in git merge and return non-zero status so that the script aborts before the server is stopped.

Possibilities I have looked for and not found include git merge --dry-run. My best line of thought is git status --porcelain | pre-merge-okay. That seems like a lot of work to make a pre-merge-okay that deals with things like benign untracked files.

I have also asked this question on Stack Overflow but received no answers.

http://stackoverflow.com/questions/20221383/
-- 
Pete Forman
Next: Konstantin Khomoutov
Message 1 of 7 in “How to pre-empt git pull merge error?”
  1. Pete FormanNov 27, 2013
  2. Konstantin KhomoutovNov 27, 2013
  3. Matthieu MoyNov 27, 2013
  4. Antoine PelisseNov 27, 2013
  5. Thomas RastNov 27, 2013
  6. Pete FormanNov 28, 2013
  7. Junio C HamanoNov 27, 2013

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.