* --skip-worktree and operations like checkout / stash /etc.
@ 2018-09-27 22:29 Raman Gupta
2018-09-28 13:35 ` Raman Gupta
0 siblings, 1 reply; 2+ messages in thread
From: Raman Gupta @ 2018-09-27 22:29 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: --skip-worktree and operations like checkout / stash /etc.
2018-09-27 22:29 --skip-worktree and operations like checkout / stash /etc Raman Gupta
@ 2018-09-28 13:35 ` Raman Gupta
0 siblings, 0 replies; 2+ messages in thread
From: Raman Gupta @ 2018-09-28 13:35 UTC (permalink / raw)
To: git
In the meantime I've created this simple script, but what a hack...
#!/bin/bash
git ls-files -v | grep "^S " | cut -c3- | readarray ignored
for x in "${ignored[@]}"; do
git update-index --no-skip-worktree -- "$x"
done
git checkout -m $@
for x in "${ignored[@]}"; do
git update-index --skip-worktree -- "$x"
done
Regards,
Raman
On Thu, Sep 27, 2018 at 6:29 PM Raman Gupta <rocketraman@gmail.com> wrote:
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-28 13:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-27 22:29 --skip-worktree and operations like checkout / stash /etc Raman Gupta
2018-09-28 13:35 ` Raman Gupta
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).