- Create a new repository at github.com. (this is your repository)
- Give it the same name as as the other repository.
- Don't initialize it with a README, .gitignore, or license.
- Clone the other repository to your local machine. (if you haven't done so already)
- Rename the local repository's current 'origin' to 'upstream'.
- Give the local repository an 'origin' that points to your repository.
- Push the local repository to your repository on github.
git clone https://github.com/other-account/other-repository.git
git remote rename origin upstream
git remote add origin https://github.com/your-account/your-repository.git
git push origin master
Now 'origin' points to your repository & 'upstream' points to the other repository. But if someone else now checks out this repository from your repository it won't have a link back to the original repository. If this is the case, create a new link to 'upstream' that points to the original repository with the following:
git remote add upstream https://github.com/other-account/other-repository.git
It's best to make changes to the code in a new branch. Create a new branch for your changes with
git checkout -b my-feature-branchYou can git commit as usual to your repository. When you want to pull changes from the original repository to your master branch use the following
git pull upstream master
No comments:
Post a Comment