简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM