79648085

Date: 2025-06-02 01:26:13
Score: 1.5
Natty:
Report link

Ah yeah, Git’s being a bit too smart for what you’re trying to do.

Even though you removed the remote, your new repo still shares the exact same commit hash as the template — so when you fetch from it again (even with --shallow-since), Git recognizes that commit and says, “Hey! I know more about this history,” and pulls it in. That’s why your shallow history gets unshallowed.

Git identifies commits by their SHA-1, and since both repos share that SHA, Git treats them as part of the same history graph, no matter what remotes you have set.

So how to fix it?
To stop Git from linking the two histories, you basically need to make the commits look unrelated. Let me show you couple ways.

At first, create a new root (break history).

Use --orphan to create a new branch that doesn’t share any history.

Like this =>

git checkout --orphan new-main

git commit -m "Start fresh"

git cherry-pick main # or cherry-pick a few commits you care about

git branch -M new-main

Now your repo doesn’t share any SHAs with the template — so Git can’t accidentally “help” you.

Next, don’t clone, just copy.

If you're using this as a template anyway, you could just copy the files instead of cloning.

Like this =>

rsync -av --exclude='.git' template/ new-repo/

cd new-repo

git init

git add .

git commit -m "Initial commit from template"

That gives you a clean, standalone repo with no shared history.

Hope this helps someone out there dealing with the same Git weirdness — don't worry, you're not crazy, Git's just very good at remembering things 😄

Reasons:
  • Whitelisted phrase (-1): Hope this helps
  • RegEx Blacklisted phrase (1.5): how to fix it?
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Arthur Boyd