I recently forked a project and applied several fixes. I then created a pull request which was then accepted.
A few days later another change was made by another contributor. So my fork doesn't contain that change.
How can I get that change into my fork? Do I need to delete and re-create my fork when I have further changes to contribute? Or is there an update button?
As of the date of this answer, GitHub has not (or shall I say no longer?) this feature in the web interface. You can, however, ask
support@github.com
to add your vote for that.In the meantime, GitHub user bardiharborow has created a tool to do just this: https://upriver.github.io/
Source is here: https://github.com/upriver/upriver.github.io
If you are using GitHub for Windows then now they have a one-click feature to update forks:
If, like me, you never commit anything directly to master, which you should really, you can do the following.
From the local clone of your fork, create your upstream remote. You only need to do that once:
Then whenever you want to catch up with the upstream repository master branch you need to:
Assuming you never committed anything on master yourself you should be done already. Now you can push your local master to your origin remote GitHub fork. You could also rebase your development branch on your now up-to-date local master.
So past the initial upstream setup and master checkout, all you need to do is run the following command to sync your master with upstream: git pull upstream master.
Android Studio now has learned to work with GitHub fork repositories (you don't even have to add "upstream" remote repository by console command).
Open menu VCS → Git
And pay attention to the two last popup menu items:
Rebase my GitHub fork
Create Pull Request
Try them. I use the first one to synchronize my local repository. Anyway the branches from the parent remote repository ("upstream") will be accessible in Android Studio after you click "Rebase my GitHub fork", and you will be able to operate with them easily.
(I use Android Studio 3.0 with "Git integration" and "GitHub" plugins.)
Starting in May 2014, it is possible to update a fork directly from GitHub. This still works as of September 2017, BUT it will lead to a dirty commit history.
Update from original
).Now you have three options, but each will lead to a less-than-clean commit history.
This branch is X commits ahead, Y commits behind <original fork>
.So yes, you can keep your repo updated with its upstream using the GitHub web UI, but doing so will sully your commit history. Stick to the command line instead - it's easy.
That depends on the size of your repository and how you forked it.
If it's quite a big repository you may have wanted to manage it in a special way (e.g. drop history). Basically, you can get differences between current and upstream versions, commit them and then cherry pick back to master.
Try reading this one. It describes how to handle big Git repositories and how to upstream them with latest changes.