Reputation: 2385
We have two different projects that are forked from the same repo (say, "repo1" and "repo2" from "parent-repo"). I want to copy only one file from repo1 into repo2. What is the "best", "most git-like" way to do this?
(Long time lurker, first time writer; I hope it's OK to put my answer below but I'm hoping someone comes up with something better, as it doesn't seem very good.)
All the repos are hosted on GitHub, but that shouldn't make any difference, right?
Upvotes: 1
Views: 102
Reputation: 2385
This is what I have so far:
git remote add sister-repo https://github.com/username/repo1.git
git fetch sister-repo
git checkout sister-repo/master sharedfiles/file1.file
Upvotes: 1
Reputation: 159
One way to do this would be to add and commit your one file to repo1 and issue a pull request to parent-repo. Repo2 would then have access to the file by running git fetch upstream
.
If you did not want to issue a pull request to parent-repo you could also have repo1 fork your repo2 then add your file to the forked repo2 and issue a pull request to repo2
Upvotes: 2