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.

top 15 comments
sorted by: hot top new old
[-] 0xDEADBEEFCAFE@programming.dev 7 points 1 day ago

A shorter example:

git clone https://codeberg.org/yourname/yournewrepo
cd yournewrepo
git reset --hard abcdef1 # commit that you want to reset to
git push --force origin

Note that instead of abcdef1 in git reset you can also use the regular expression syntax. So if the commit was named Last release before unwanted changes you would say git reset --hard ':/Last release before unwanted changes'.

[-] zener_diode@feddit.org 5 points 1 day ago* (last edited 1 day ago)

You should be able to just fork it normally, then reset (or is it revert?) to the commit you want.

[-] bignose@programming.dev 5 points 1 day ago* (last edited 1 day ago)

It may depend where the project is and what you want to bring with you.

If you're asking solely about the Git repository: you need to find exactly which commit is the latest one you want to bring, and specify that commit identifier (the hash of that commit) as the “starting point” when you create a new branch.

git branch […] []

https://git-scm.com/docs/git-branch

So, clone the repository locally however you need to do that. Then, in your local repository, modify what the branches point to:

e.g. If you determined the latest commit you want to bring, has commit identifier “deadbeefbad1dea”, you can create the branch named “before-the-slop”:

git branch before-the-slop deadbeefbad1dea

Now the new branch “before-the-slop” has all the commits up to that, and no further. That's what you'll base your fork on.

git branch before-the-slop

git rev-parse HEAD # → deadbeefbad1dea

Then rename the old “main” or whatever branch, to something like “sloppified-project-main” that gets it out of the way; rename your “before-the-slop” branch to “main”; and set “main” as the default branch in your repository.

git branch --move main sloppified-project-main

git branch --move before-the-slop main

git config set --local init.defaultBranch main

Some time later, when you've confirmed your repository is how you like it, delete the “sloppified-project-main” branch:

git branch --delete sloppified-project-main

and breathe easy.

[-] FizzyOrange@programming.dev -4 points 1 day ago

You know you can just ask AI trivial questions like this? This is well within its capabilities.

[-] ZILtoid1991@lemmy.world 3 points 1 day ago
[-] FizzyOrange@programming.dev -1 points 1 day ago

I mean... It legit can though. You may hate AI for coding but I don't see why you wouldn't use it for questions like this. Do you not think it could answer this question?

[-] HubertManne@piefed.social 1 points 1 day ago

why ask ai for something like this. You know you could just ask a forum of people interested in the topic. I don't get why people who want to participate in a forum then feel people should not bring up things to discuss in a forum for the life of me.

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

Because it will give you an answer instantly? There are plenty of other things you can bring to forums - news, projects, etc.

[-] HubertManne@piefed.social 2 points 1 day ago

and you could try ai on all those other things and you can just talk in a forum for this. Some people don't really use ai. Heck I mostly just use it to sorta evaluate it. I have high hopes for future open source local uses that are more to my liking but what we have now is something I take with a grain of salt.

[-] FizzyOrange@programming.dev 1 points 2 hours ago

I'm not sure what you're trying to say. Why would you announce news to AI?

[-] HubertManne@piefed.social 1 points 2 hours ago

so like. im not here for news. im here for communication with humans. so it depends I guess on the reason you are here.

[-] 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 4 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