gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

gh stack modify fails with untracked files

Open safarmer opened this issue 6 months ago • 7 comments

gh stack modify preconditions fail if the current working directory has any untracked files and fails with the following message that seems to imply that untracked changes shouldn't be a problem, as there is nothing to stash or commit.

✗ uncommitted changes in working tree
Commit or stash your changes before running modify

Code that performs the check: https://github.com/github/gh-stack/blob/5ed5693ed6fcfa34228312abb09553e2580b6670/internal/git/gitops.go#L576

Perhaps this should ignore any lines starting with ?? ?

safarmer avatar Jun 01 '26 00:06 safarmer

Instead of ignoring the files, we could prompt the user if they want to continue with untracked files. Any thoughts?

@skarim @safarmer

yashas-hm avatar Aug 07 '26 16:08 yashas-hm

I wouldn't be opposed to a command line flag, and would probably like to see a matching config for setting the default behaviour.

Looking at the AI comments on the linked PR, the justification for not blindly performing the operations are sound. In reality, I end up with several untrack files or folders. I work in a large monorepo and I don't want to change the .gitignore files, and have temporary configs and runtime files that I don't want to commit. I do not expect to have conflicts with other incoming changes.

safarmer avatar Aug 08 '26 02:08 safarmer

I'm in the same boat as @safarmer, it's frustrating to have to move out of the way a bunch of unrelated files that have nothing to do with the stack.

benoit-nexthop avatar Sep 15 '26 07:09 benoit-nexthop

Another option might be to stash untracked files once it is confirmed that only untracked files are present. The unwind and completion steps could both look for a stash tagged with a message identifying and apply it. In the case of an incoming conflict, the stash would remain and the user would be able to decide on how to resolve the conflict without losing any data.

safarmer avatar Sep 15 '26 23:09 safarmer

Stash is a good option--unless a file is large. I happen to have a very large tar.gz file (2GB)! that is only there for awhile, but I do need it until I don't.

ethanb-lvt avatar Oct 01 '26 17:10 ethanb-lvt

gh stack rebase has this too since 0.2.x

> gh stack rebase
❌ uncommitted changes in worktree /home/user/repos/project; commit or stash them before continuing

> git status --short
?? .local/

had to

echo '.local/' >> (git rev-parse --git-common-dir)/info/exclude

to make it work

mrt181 avatar Oct 05 '26 09:10 mrt181

I find gh stack rebase and gh stack sync to be awkward for not operating when I have untracked files in the worktree. I was able to work around it today by manually rebasing stack branches on to each other and then running gh stack submit.

marksvc avatar Nov 03 '26 19:11 marksvc