Open source projects are beautiful because everyone can work on them and contribute. If you are a team member of an open source project, it’s easy – you can just create your own branch, push that branch to the main github repository and create a merge request. If you are not a team member of the project, you can still contribute, but you have to copy (“fork”) the project first into your own account. Your copy is then magically linked to the original repository and you find yourself with three copies (the original one, the forked one in your github account and your local copy on your computer). The following instructions are intended to help you work across those three copies in an efficient way.
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 email@example.com:macolo/django-cms.git
Then add the upstream repository as second remote:
git remote add upstream firstname.lastname@example.org: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
git checkout --track upstream/develop
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:
If you are happy, then add the changes to the “stage”:
git add .
Check again (stuff has now turned green = added to stage)
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.