Skip to content
Patricio Cubillos edited this page Dec 3, 2015 · 4 revisions

This wiki contains some basic steps to follow if you want to make contributions to the Transit Git repository.

Table of Contents:

Work in branches:

When editing the code, do not directly work in the Default branch (master). Rather create a new branch with the checkout git command. For example, create a branch named 'develop':

git clone --recursive https://github.com/exosports/transit transit/
cd transit
git checkout -b develop

Edit the code, and commit your changes (See Editing code).
Now push your edits back into Github:

git push origin develop

Once you are ready to merge your branch into the master, browse into the repo's webpage, click the branches button, and then click the 'New pull request' button. Do not merge unless you are Patricio, Jasmina, or Joe; or unless you have explicit approval from them to merge.

Editing code:

Once you are done with you changes and you checked that Transit runs, use the status git command to see the edited files:

git status

or with the -uno argument to see just the files that belong to the repo:

git status -uno

Add the files that you want to update in the branch:

git add README.md

Please, never do:

git add -a

Because the chances are that you will add a bunch of files that you didn't want to add to the repo. Then when another user finds out, which will make him somewhat mad. If you need to add a large number of files, you can add all of them in a single step, e.g,:

git add README.md transit/src/transit.c transit/src/tau.c 

Run status again, just to make sure you are adding the files you really want to add:

git status -uno

Now you are ready to commit, use the -m argument to include a descriptive message of your changes, e.g.:

git commit -m"Added John Doe to the Team Members list in the README.md."

You can include hyperlinks to specific commits by specifying the commit checksum ID:

git commit -m"Fixed the bug that John Doe introduced in 62db43d."

or even, you can close issues by including the issue ID, e.g.:

git commit -m"Added John Doe to the Team Members list in the README.md. Resolves #1."

Rebase:

What if the Default branch added new commits while you were working on your branch? No problems, rebase let's you incorporate those changes into you branch, so you can keep developing. First make sure that you pulled the most current master code to your working directory:

git checkout master
git pull origin master

Then you can rebase master into your develop branch:

git checkout develop
git rebase master develop
git push origin develop -f

Now, keep working.

Commit history:

To display the commit history, run the log command:

git log

Diff:

Show the files changed between two commits (e.g. between commits 8bf81be1 and 2f911e6f):

git diff --name-only 8bf81be1 2f911e6f