6
How do I fork a project at a given point?
(lemmy.world)
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
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
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?
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 setHEADto that commit, along with the contents of the working directory. You are the free to push to whichever git forge you are hosting on.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?
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 resetsuggestion was intended to reset whatever the default branch of the upstream repo was (probably master).