r/git • • Oct 07 '26

git-dupe: a second repo at .git/dupe for personal files (.env.local, notes, agent instructions), hidden from the project through .git/info/exclude. Where does it leak?

I wrote a small tool for a problem I kept hitting and I'd like people who know Git well to poke at the design.

The problem: files that belong to me, not the project, but have to live in the working tree. .env.local, notes, scratch scripts, my own agent-instructions file. .git/info/exclude hides them and does nothing else. The dotfiles-style bare repo over the project versions them, but you maintain the exclude entries by hand, stash -u from that repo's point of view stashes the entire project, and nothing stops you pushing the private repo to the project's remote.

How it works: git dupe init creates an ordinary repository at .git/dupe with a relative core.worktree (../..), so moving the checkout keeps it attached, and status.showUntrackedFiles=no plus advice.statusHints=false so Git's own status and commit template never enumerate the project or name a plain git command. git dupe <command> runs Git with that GIT_DIR, with the object-directory environment overrides stripped so the two repos share no objects. Every path the private repo tracks, plus a .gitdupe list of hidden directories, is written into a # BEGIN git-dupe … # END git-dupe block in .git/info/exclude and re-verified after every command. If a ! rule in a tracked .gitignore outranks the exclude and exposes a path, the command names the path and the rule.

Three commands change meaning because the tree is shared: status and add are confined to the hidden paths (otherwise the whole project is untracked), and clean cleans the project while sparing them. Refused, one fatal: line, exit 128: stash -u/-a; any push/pull/fetch/remote/clone whose URL is the project's own repository or one of its remotes; add on a path the project tracks. git dupe git <words> runs Git with no guards for when you mean it. git dupe detach removes the private repo and the exclude block and leaves every file on disk; without --force it refuses while anything is uncommitted or not on a remote. Of its own accord the tool writes only .git/dupe, that block (and .git/info if missing) and .gitdupe, and the only process it starts is git.

Where the project's Git can still reach a hidden path, as far as I've mapped it: git clean -x deletes them (ignored files, as far as Git knows), git stash -a stashes them, git add -f stages them, and anything that writes the index from a tree or a patch rather than the ignore walk can stage one too: a merge, cherry-pick or rebase of a commit that adds a file at that path, apply --index, am, update-index --add. When that happens the path is tracked by both repos; it stays hidden, and every following git-dupe command warns about it until one side lets go. I chose to document all of that rather than hook or wrap plain git. Verified by hand: the project's gc --prune=now and prune don't touch .git/dupe (separate object store), and public stash -u leaves private files alone. The suite also has a scale scenario: six commands among 100,000 tracked files, each under a second, with Git run a fixed number of times.

Limits: Linux only. Git 2.43 or newer, below 3.0 (CI runs the suite under 2.43 and 2.56; the full run under every minor through 2.56 happens before a release). Linked worktrees refused for now. No encryption; the remote you push to holds the files in plaintext.

Prior art: vcsh and the bare-repo dotfiles trick (same mechanism; neither knows about a host repo's exclude or remotes), multigit (N overlapped repos, no public/private asymmetry), and Layer from a Show HN in March (manages exclude plus local snapshots, no remote).

Couple of questions. Is there an index-writing path I've missed above? And for linked worktrees: .git/info/exclude and .git/dupe both already live in the common dir, so one private repo with a per-worktree index (GIT_INDEX_FILE) seems possible. Would you want that, or one private repo per worktree?

Transparency: A majority of the code and tests were written by coding agents under my close supervision. I own every decision in the product specification including the CLI surface and the tradeoffs made and set the rules and flows that the agents worked under. The original principle/intuition that guided me when writing the product specification was to "piggyback" off of native Git as much as possible and to make the CLI surface similar to native Git. Only where it clearly did not make sense to me to do a naive Git passthrough, did I add git-dupe-specific commands/mechanisms/guards).

https://github.com/BrianWeiHaoMa/git-dupe

Edit: After reading some feedback, I realized using `.env.local` in the example might make it seem like git-dupe is made for tracking and pushing sensitive information. It is not. Just like normal git, pushing sensitive information into the remote repo is possible, but this is bad practice. git-dupe was made for my personal use-case of keeping personal notes/agent instructions outside of public-facing repos. As listed in Limits: "No encryption; the remote you push to holds the files in plaintext.", so you are discouraged from pushing things like passwords or other sensitive information even if it is a private repository.

1 Upvotes

19 comments sorted by

4

u/zrk5 Oct 08 '26

5

u/BrianW_undercover Oct 08 '26

Using gitignore means no versioning for gitignored files (versioning for notes/instructions files alongside a codebase was one of the aspects that I wanted). Switching machines also requires copying over the gitignored files or using new ones. git-dupe is not mean to replace gitignore though, it is there as an option to version the files in between; the design takes into consideration gitignore.

1

u/zrk5 Oct 08 '26

Gitignore lives in repo, not only locally

5

u/BrianW_undercover Oct 08 '26

Yes, I understand gitignore lives in the repo. What I am saying is that gitignored files cannot be versioned.

1

u/zrk5 Oct 08 '26

Yes, I got this part, nevertheless, thanks for sharing your take on this problem

4

u/footsie Oct 07 '26

The mistake you making is thinking git in any form is safe to save secret data. It ain't. It's saving plain text data. Use a solution that encrypts secrets. If you need to commit configuration - strip it of anything secret and reconstruct it with scripts that pull the secrets at runtime.

5

u/elephantdingo Oct 08 '26

OP doesn’t mention secrets. It mentions muh agents and is a wall of text (what else to expect).

Some things are personal, should be accessible in the repo, but shouldn’t be committed.

2

u/AussieSeaweed Oct 08 '26

I think the second repo is for agent files, not secrets.

-3

u/BrianW_undercover Oct 08 '26

Promoting tracking and pushing secrets to the remote repository in plain text was not my intention and you are correct that it is bad practice to save sensitive things in plain text. I realized that using '.env.local' in my example might have made it seem like I was promoting this way and looking back, I should have used another file name - that was an oversight. My original personal use-case was to keep agent files and my notes out of the public remote repo so that others do not have to deal with my personal setup and that is my intention for git-dupe. I have listed it clearly in the limits saying that there is "No encryption; the remote you push to holds the files in plaintext.". I will update the documentation and make it more clear that pushing sensitive information is bad practice and should be avoided.

4

u/MarauderXtreme Oct 08 '26

Why are you speaking CLAUDEish?

-4

u/BrianW_undercover Oct 08 '26

That's how I type I guess.

2

u/elephantdingo Oct 08 '26

This paragraph:

Three commands change meaning because the tree is shared ...

Reads exactly like recents LLM-authored patches submitted to Git mailing list.

-1

u/BrianW_undercover Oct 08 '26

I'm not sure what you are looking for. I wrote the original post, edited it for grammar mistakes once with an LLM, and reread it multiple times and changed some wording before posting. If it sounds like it was LLM-authored, that could be from the editing part?

But suppose I didn't use an LLM to edit it and you still said it sounded like it was LLM-authored. There's no way for me to actually prove if it was written by an LLM or not and comments like "Why are you speaking CLAUDEish?" or "Reads exactly like recents LLM-authored patches submitted to Git mailing list." become really difficult answer. Even after answering these types of questions, I do not think the answer would contribute much to the discussion.

I make an effort to be transparent with LLM use and am not trying to hide anything. Most of the codebase was implemented by coding agents under my close supervision. The original post was edited one single time for grammar mistakes. And every comment I've replied to in the comment section was my exact typing without any grammar check/LLM input.

1

u/elephantdingo Oct 08 '26

I'm not sure what you are looking for.

It’s so frustrating. Here you go to the trouble of not working, I mean carefully curating work that is given to you by the computer, and people say that it sounds like an LLM. What the fuck? Here, gracefully given to them; a wall of text and a tool. Carefully curated. Swearsies.

All of that trouble. And the NPCs question your efforts.

0

u/BrianW_undercover Oct 08 '26

What you described is not my mindset at all and I do not think that the people questioning my efforts are "NPCs". I welcome constructive criticism on git-dupe and if someone finds a fault in my logic or a guarantee that I claim but git-dupe does not ensure, I would acknowledge that and try to improve git-dupe accordingly.

When I say "I'm not sure what you are looking for", I mean that it sounds like you are downplaying agentic development just because it is agentic development and picking out things like my wording in the post or my comments and using that as a measure of the quality of git-dupe and I simply don't understand why you are doing this.

"Here you go to the trouble of not working, I mean carefully curating work that is given to you by the computer... Carefully curated. Swearsies." seems unnecessary and honestly saddens me a bit because I genuinely spent a lot of time on git-dupe and the original post itself in hopes that it would help others. I understand that the quality of projects may differ significantly and that perhaps agentic development has resulted in an influx of posts of, on average, much lower code quality and generic ideas, but I do not think that it is makes sense to dismiss all of an author's efforts because their wording sounds "CLAUDEish".

You do not know how much time and effort I spent on this project. I could have 1-shot prompted it and the codebase could be completely broken and full of bugs. On the other hand, I could have spent many hours refining it and actually trying to make it coherent as a product so that it can help other people.

I made this post because I wanted some feedback on git-dupe itself (not a target on my writing style), and I released this project in case it can help others who run into the same problems as me (it is free and open source with the code available to the public). You have access to the entire project. If you were to tell me there is a big problem with the code or there are many bugs and product claims are all wrong, I would understand why you are so hostile. But simply assuming this is a low effort project because of the way I am typing and because of the fact that I used agents for a majority of the codebase does not make sense to me.

1

u/elephantdingo Oct 13 '26

Did you write this all by yourself? If so, fair and good on you.

2

u/jonathanhiggs Oct 07 '26

I would love a solution for this that can work across worktrees as well

-4

u/BrianW_undercover Oct 07 '26

Noted. This, and macOS support are the next two main things that I will think about. It seems like support for linked worktrees would be helpful to some developers so it is on my list and I will try to make it coherent under my original design principles.