How to work from a fork with an upstream repository

First, fork the upstream project on github.com into your own domain. Then get the clone URL from your newly forked repo in your domain, and clone the repo to your local environment:

git clone git@github.com:macolo/django-cms.git

Then add the upstream repository as second remote:

git remote add upstream git@github.com:django-cms/django-cms.git

Then switch to the upstream branch that you would like to eventually merge into:

git pull upstream develop
git checkout develop

OR

git checkout --track upstream/develop
git pull

From that fresh, up-to-date branch you can now create your own “feature” branch:

git checkout -B mario-test

Now you can make your changes on the mario-test branch (in an editor). Then show a list of your changes:

git status
git diff

If you are happy, then add the changes to the “stage”:

git add .

Check again (stuff has now turned green = added to stage)

git status

Now you are ready to prepare a commit:

git commit -m "speaking short description of the changes, also links to the issue will work magically"

You can create several commits locally.

You can now push this commit or commits on your local feature branch to your remote forked repo:

git push origin

Now you can go to github.com to your forked repo and create a Pull Request to a branch in your upstream repository, from your feature branch in your forked repo.

Leave a Reply

Your email address will not be published. Required fields are marked *