6

I'm thinking on writing some tutorial on de-sloppifying some open-source projects, with I'm likely ending up at least starting some of them.

you are viewing a single comment's thread
view the rest of the comments
[-] stembolts@programming.dev 0 points 1 day ago* (last edited 1 day ago)

Reading your comment literally, that you want a step by step description.

Assuming you are starting a brand new repo.

Clone.
Identify commit from which to fork.
~~Checkout commit by hash.~~
~~Delete .git.~~ get reset --hard some-hash
~~git init~~
~~git add, excluding whatever for whatever reason.~~
~~git commit -m "Init fork."~~

That's what makes sense to me thinking through it. No idea if it works that way, never tried it. But that is what I would try first.

Lemme know if I fucked up anything.

Now my own questions, the other comments seem to be maintaining a reference to the original repo, is that what is going on?

[-] expr@programming.dev 5 points 1 day ago

There's no sense in deleting a project's history before the fork, which is what that would do.

It's really quite simple:

git reset --hard <some-commit-hash>. This will set HEAD to that commit, along with the contents of the working directory. You are the free to push to whichever git forge you are hosting on.

[-] stembolts@programming.dev 1 points 1 day ago

That makes sense. I'll amend my comment.

Couldn't you also git checkout -b hash for the same result, then fork with the new branch?

Or are the results different in some way?

[-] expr@programming.dev 2 points 1 day ago

Sure that works too, though you would likely need to configure your git forge to treat that new branch as the master branch. A branch is ultimately just a pointer to a particular commit, though usually git forges treat one particular branch as "special" (it's the default branch used for clones, and typically disallows direct pushes). This is usually the master or main branch. So my git reset suggestion was intended to reset whatever the default branch of the upstream repo was (probably master).

this post was submitted on 15 Oct 2026
6 points (68.8% liked)

Git

4800 readers
38 users here now

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 3 years ago
MODERATORS