Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world

13 replies

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

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

6

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
exprreply
programming.dev

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

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
programming.dev

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

-3
programming.dev

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
piefed.social

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
programming.dev

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

1
piefed.social

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

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

You reached the end

How do I fork a project at a given point? | Spyke