Github Cheat Sheet
Clone this wiki locally
The following commands are a short rewrite of github's documentation about the process of forking, pushing your changes, and pulling in changes from the upstream repo.
As the first step you will need to install git, configure it and upload your SSH keys to github.
To prepare your working copy start by creating a fork of Lernanta's git repository on the web interface, and then clone it by running:
git clone firstname.lastname@example.org:<your github username>/lernanta.git cd lernanta git remote add upstream git://github.com/p2pu/lernanta.git git fetch upstream
If you need to create many user accounts on your dev environment run this on the django shell (python manage.py shell)
from django.contrib.auth.models import User from users import models for i in xrange(100): username = 'user-%s' % i email = '%email@example.com' % username user = User(username=username, email=email) if i == 0: user.is_superuser = True user.is_staff = True user.save() profile = models.create_profile(user) profile.set_password('password') profile.save()
After fixing a bug or implementing a new feature, there are a couple of commands which can be useful to run:
To update the migrations in case you changed the database schema (see or migrations docs for more details):
To recreate the dev database in case the database schema changed:
python manage.py migrate --all --delete-ghost-migrations
To check that your changes follow the Style Guide for Python Code:
pep8 -r --exclude=migrations .
To detect a couple of simple but common errors in the Python source code:
pyflakes apps/ | grep -v migrations
To run the test framework:
python manage.py test
To recreate the test database before running the tests (in case the database schema changed):
FORCE_DB=True python manage.py test
Then is time to publish your changes in your fork: github.com/<your github username>/lernanta.
git commit git push origin master
If you're working on more than one task, work should be done on branches so that multiple commits don't end up in one pull request. First, create the branch:
git branch <branchname> git checkout <branchname>
Commit as normal. Push back with:
git push origin <branchname>
You can switch to your branch in github and submit a pull request. When done, switch back to your master branch. This will revert all your files to the state of the master branch:
git checkout master git merge mybranch
If at some point the Lernanta's repository gets updated by someone else, you can update your working copy by running
git fetch upstream git merge upstream/master
git pull upstream master
Let us know about your awesome work by making a pull request in your forks' web page (github.com/<your github username>/lernanta ).