RetroFed Forums
Your home away from modern life.
How do I fork a project at a given point?
Post Reply
AuthorMessage
ZILtoid1991
lemmy.world
ZILtoid1991@lemmy.world
Joined: 2024-03-16
Posted:   Subject: How do I fork a project at a given point? Quote

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.

6   Original
bignose
programming.dev
bignose@programming.dev
Joined: 2025-03-03
#2 Posted: · edited   Subject: Re: How do I fork a project at a given point? Quote Reply

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.

6
zener_diode
feddit.org
zener_diode@feddit.org
Joined: 2025-04-06
#3 Posted: · edited   Subject: Re: How do I fork a project at a given point? Quote Reply

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

6
0xDEADBEEFCAFE
programming.dev
0xDEADBEEFCAFE@programming.dev
Joined: 2023-08-27
#4 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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'.

7
stembolts
programming.dev
stembolts@programming.dev
Joined: 2023-07-11
#5 Posted: · edited   Subject: Re: How do I fork a project at a given point? Quote Reply

[deleted]
0
FizzyOrange
programming.dev
FizzyOrange@programming.dev
Joined: 2023-09-24
#6 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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

-3
ZILtoid1991
lemmy.world
ZILtoid1991@lemmy.world
Joined: 2024-03-16
#7 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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

One up your trolling!

3
expr
programming.dev
expr@programming.dev
Joined: 2023-07-03
#8 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

[deleted]

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.

5
stembolts
programming.dev
stembolts@programming.dev
Joined: 2023-07-11
#9 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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 &lt;some-commit-hash&gt;. 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.
[deleted]
1
FizzyOrange
programming.dev
FizzyOrange@programming.dev
Joined: 2023-09-24
#10 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

One up your trolling!

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?

0
expr
programming.dev
expr@programming.dev
Joined: 2023-07-03
#11 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

[deleted]

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).

2
HubertManne
piefed.social
HubertManne@piefed.social
Joined: 2025-03-13
#12 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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?

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.

2
FizzyOrange
programming.dev
FizzyOrange@programming.dev
Joined: 2023-09-24
#13 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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.

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

1
HubertManne
piefed.social
HubertManne@piefed.social
Joined: 2025-03-13
#14 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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

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.

2
FizzyOrange
programming.dev
FizzyOrange@programming.dev
Joined: 2023-09-24
#15 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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.

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

1
HubertManne
piefed.social
HubertManne@piefed.social
Joined: 2025-03-13
#16 Posted:   Subject: Re: How do I fork a project at a given point? Quote Reply

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

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

1
Post Reply
Back to top