Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fork a Github repo into another repo as part of a larger project

Perhaps I'm missing something here, but I've looked and I want to do something that looks pretty simple, but I've yet to figure out (or find someone who has) how to accomplish it.

  • I have a project, and I've found a Github repo that contains content I would like to use as part of it.
  • I want to fork that repo's content into my project (another repo)
  • I want the connection of the fork to remain in case of changes to the original file (otherwise I would've simply simply copy/pasted at the beginning -- also, I would like the option of issuing pull-requests).

I've tried to simply, git clone https://github.com/dave/repository_of_dave.git (and variations) but then there is still a connection with all of the content from Dave's repo. Is copy/pasting the only way to go here?

like image 476
sos12 Avatar asked Apr 11 '14 03:04

sos12


People also ask

Can you fork a repo into another repo?

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.

What is the difference between forking and cloning a repository?

Any public Git repository can be forked or cloned. A fork creates a completely independent copy of Git repository. In contrast to a fork, a Git clone creates a linked copy that will continue to synchronize with the target repository.

Is forking the same as branching?

Forking creates a full copy of your repository, whereas branching only adds a branch to your exiting tree. The file size of branch can vary depending on the branch that you are on. Under the hood git readily accesses the different files and commits depending on what branch you are using.

Can you fork a repo on GitHub?

Most commonly, forks are used to either propose changes to someone else's project to which you do not have write access, or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.


1 Answers

Submodules are indeed a good fit, as your repo will only record a gitlink (special entry mode 160000) to record the commit of the submodule repo you are using.

Don't forget that this submodule is a git repo of its own, which means:

  • you can make commits in it (see "true nature of submodules")
  • you can make it follow the latest commits of branch (see "git submodule update")
  • you can add remotes to it (like a remote to the original repo you have forked, in order to fetch updates from said original repo, see "What is the difference between origin and upstream in github")
like image 112
VonC Avatar answered Sep 28 '22 16:09

VonC