Reputation: 1803
I'm busy with a project which uses some libraries from
git clone http://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
I've downloaded the above code and put it in my code and now want post my code on github.
I also want to make sure that the latest code from adafruit is always used so is there a way I can put a link in my code to the adafruit so that it always pulls the latest version.
Ive done some reading on git and I think this might be called a fork? When putting my code do I put the adafruit code in my repository, or is there someone I can put a link in to the original?
Upvotes: 2
Views: 7378
Reputation: 2785
As you have already cloned the repository locally and made modifications, you should take a few steps to create a fork (for traceability to the original) and setup the appropriate remotes to synchronize with.
Go to http://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code and click the "Fork" button
Copy the Git repository URL for your new Fork
On the terminal, in your project directory, add a remote:
git remote add fork <repo-fork-url>
`git remote update
`git fetch
git checkout master
git pull -rebase origin master
git branch --unset-upstream master
git push -u fork master
From here on, you can edit and commit to your local repository, git push
and git pull
to sync with your Fork on GitHub, and git pull origin master
to retrieve the latest commits from the original repository.
Upvotes: 1
Reputation: 97
Yes, by forking your can use pull request to send them your code for review which they merge in their project if they want. To pull the latest changed from their repository see also:
git fetch upstream
git merge upstream/master
It automatically merges if no conflicts but sometimes there are so then you will have to do it manually.
Upvotes: 0
Reputation: 308031
Unless you're already a contributor to that project, you won't be able to push directly to their repository.
In that case the general usecase is to fork the project (i.e. create a copy under your name) and work on that. You can then create pull-request to ask them to pull specific changes from your repository.
This GitHub Article explains the process and also tells you how to keep your fork up-to-date (if you don't do anything special, it's basically just a snapshot).
Upvotes: 1