We have a situation where were are using git to stash myriad scans (images) and do not wish to preserve them on the local machine once set on up; however, git is seeing each loc
(edit: package up the payload as a self-contained script)
You're after a nearly status-only local repository that tracks the existence of everything you've ever created but keeps the contents of only the most recent stuff (after pushing everything upstream). Presuming you never reuse a pathname, here's the ritual:
One-time setup:
Create and push an everything branch that tracks every image you've got so far. Base a (local-only) worktree branch off that.
git checkout -b everything # this will be the branch you push
git push origin everything # .
git checkout -b worktree # you'll stay on this branch
Work (almost) as if you didn't want to do anything special:
Everything that needs preserving upstream is on the everything branch, and you've got worktree checked out. Remove images you're done with from the worktree, make new images there that need pushing, and commit the new worktree state:
# work work:
rm -r anything/ you\'re/ done with
create new images
git add -A . # good gitignore patterns make life easy
git commit
To do the requested work, run
merge-push-and-cleanup # the script below
After which everything's stored upstream, nothing redundant remains locally, and you're ready for more work.
The merge-push-and-cleanup script:
#!/bin/sh
# Git can do "index-only" merges when the content doesn't need to be examined,
# you can casually create sideband indexes, and `git commit-tree` works on any
# tree in the repo.
(
# ^ subshell to keep G_I_F export local
export GIT_INDEX_FILE=.git/sideband-index
# make a merged index that includes everything from both branches, by
# starting from an empty merge base so all files show up as additions.
git read-tree -im $(git mktree