Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How do you fork with the intention of breaking ties with the original repo?

Tags:

git

I'd like to fork a repo with the intention of breaking ties with the original repo. There will be no pull requests or any future merges whatsoever. The new repo will have a new project name. The only reason I don't copy the source files and start an entirely new repo from scratch is because I'd like to preserve the commit history. How do I do this?

Clarification: I do use Github. I wasn't previously aware that there was anything Github-specific. For my specific needs, I have a git repo that houses two separate projects (one Scala, one Java). The files for the two projects have started interfering with each other, so I'm going to fork the repo, and in the new repo delete all the files for the Scala project. In the original repo, I'll delete all the files for the Java project.

like image 930
dhalsim2 Avatar asked Jan 23 '15 18:01

dhalsim2


People also ask

How do I sync forked with original repo?

To sync your forked repo with the parent or central repo on GitHub you: Create a pull request on GitHub.com to update your fork of the repository from the original repository, and. Run the git pull command in the terminal to update your local clone.

Can a forked repo pull from original?

Configuring Git to sync your fork with the original repository. When you fork a project in order to propose changes to the original repository, you can configure Git to pull changes from the original, or upstream, repository into the local clone of your fork.

How do I fork my own repossession?

You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com. Source: GitHub Guides.


1 Answers

If you plan to keep everything (or almost everything) from the original project, I would just fork it as normal and begin modifying it heavily.

If you only want a small subset of the files, you could use filter-branch to remove parts of the repository you don't want from the entire history. This step will change every commit SHA and make it impossible to pull or merge (at least automatically) from the original. It's not necessary to do this, though.

If you are worried about accidental cross-project contamination you could use the filter-branch step just to ensure the history is incompatible, even if you are keeping most of the files. If there's nothing to delete, you could do something as simple as rewriting the commit message of the initial commit.

If this is a github question, I think what you'd have to do is clone the repo to your local machine, create a new project on github (rather than forking the original) and then push to the new project. Github won't figure out the relationship, as far as I know. But if you're worried, there's still filter-branch between the initial clone and the push.

like image 194
Ben Jackson Avatar answered Oct 25 '22 14:10

Ben Jackson