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

Re: skip-worktree autostash on pull

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2023, 21:53 UTC
Message-ID
<xmqq7cosifq3.fsf@gitster.g>
In-Reply-To
<ZQN9Azt/K28WLfqH@tapette.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 5 quoted lines
> Your particular case is one of many reasons we suggest this approach.
> There is in fact an --autostash argument in git pull, as well as git
> rebase, both of which work as you might expect, but in general they
> still won't work properly with --skip-worktree and given the FAQ entry
> above, we wouldn't add support for that in the option.

As you mentioned, "--autostash" will move away the local change while your otherwise clean working tree needs to be updated from the upstream via "git pull" (or "git pull --rebase"). So the only thing the user may want to be careful would be "git commit -a" (and "git add -u"), I would think. A pre-commit hook should be able to stop you from committing with local changes to these selected paths you want to keep following the upstream _with_ local changes (i.e. run "diff --cached --name-only HEAD" and exit with non-zero when one of these paths appear in its output). Upon seeing such a failure, you can "git stash" the changes, then "git commit" again. And you do not need to abuse assume-unchanged or skip-worktree for doing that.

Previous: brian m. carlson
Message 3 of 3 in “skip-worktree autostash on pull”
  1. Blake CampbellSep 14, 2023
  2. brian m. carlsonSep 14, 2023
  3. Junio C HamanoSep 14, 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.