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

--skip-worktree and operations like checkout / stash /etc.

From
Raman Gupta <rocketraman@gmail.com>
Date
Sep 27, 2018, 22:29 UTC
Message-ID
<CADF5XCygzArjd9rgY_x_BqnhL5QpFL1CO1JjOHnBQc3HFn_JdQ@mail.gmail.com>

The comand `update-index --skip-worktree` seems to be an ideal way to tell git to locally ignore some modified files. However, this seems not to play well with very common commands like `checkout` and `stash`.

$ git checkout other-branch
error: Your local changes to the following files would be overwritten
by checkout:
        path/to/ignored/file
Please commit your changes or stash them before you switch branches.
Aborting
Ok, well lets try stashing:

$ git stash save No local changes to save

Ok, lets try a checkout with a merge:

$ git checkout -m other-branch error: Entry 'path/to/ignored/file' not uptodate. Cannot merge.

Ok, lets force this sucker:

$ git checkout -f other-branch error: Entry 'path/to/ignored/file' not uptodate. Cannot merge.

Ok, at this point I'm wondering, do I really need to --no-skip-worktree all the ignored files, do my `checkout -m`, and then ignore them again? Umm, no, that ain't gonna work.

I'd love for git to just check if my worktree-skipped changes will merge cleanly into the target branch, and if they do so, go ahead and do that merge (with perhaps a notification printed to the console) and keep the skip worktree status. If the merge ends up with a conflict, then feel free to no-worktree-skip it and show me merge conflicts.

Regards, Raman

Next: Raman Gupta
Message 1 of 2 in “--skip-worktree and operations like checkout / stash /etc.”
  1. Raman GuptaSep 27, 2018
  2. Raman GuptaSep 28, 2018

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.