How to comprehensively check for unsaved work?

Viewed 58

I'm working with a large number of git repositories that aren't terribly small. Disk space is an issue so I need to remove some repos I'm not using to make room for others.

How do I comprehensively check for unsaved work before rm -rf project/?

I've googled around and haven't found anything that's a direct answer. I have cobbled together this alias that so far seems sufficient, if a bit ugly in output.

    unsaved = "!f() {  \
                echo '=====[ Unpushed commits ]==================================================';  \
                git branch -v;  \
                echo '=====[ Uncommited work ]===================================================';  \
                git status;  \
                echo '=====[ Uncommited stashes ]================================================';  \
                git stash list;  \
                echo '=====[ Unpushed tags ]=====================================================';  \
                git push --tags --dry-run;  \
               }; f"

This checks in all the corners I know of for work that would be lost if the repo is deleted. Pretty self-explanatory, but a couple of notes: LFS changes should be revealed by the git status command; changes in submodules should similarly be revealed. Orphaned commits are not handled, would be lost on repo deletion, but that's okay for my current purposes. I have an alias for finding all orphans if I change my mind later.

Have I missed anything?

I just remembered worktrees are a thing. I don't know how to handle that right now since I've never worked with them. A quick google doesn't help. Are worktree changes reflected in git status?

1 Answers
Related