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.