Repository navigation
Using GitHub
This document was appropriated from Cataclysm: Dark Days Ahead's repo.
To contribute, fork the repository here on Github, make your changes, then send a pull request for review of the code by the other party.
There are a couple of guidelines we suggest sticking to:
- Add this repository as an
upstreamremote. - Keep your
masterbranch clean. This means you can easily pull changes made to this repository into yours. - Create a new branch for each new feature or set of related bug fixes.
- Never merge from your local branches into your
masterbranch. Only update that by pulling fromupstream/master.
Our policy is yet to be written up. For now, be generally clean and consistent with your indentations, comments, and so on.
Doxygen generates documentation. We may employ it at some point.
Helpful pages:
http://www.stack.nl/~dimitri/doxygen/manual/commands.html
http://www.stack.nl/~dimitri/doxygen/manual/commands.html
http://www.stack.nl/~dimitri/doxygen/manual/commands.html
- Doxygen comments should describe behaviour as found on the outside, not the implementation. However, it may be somewhat necessary to describe implementation at times.
- Describe things that aren't obvious, as if foreign eyes are your audience.
- Don't describe redundantly. E.g.
/** Mapis not a helpful comment. - When documenting something, describe how it interacts with other components, not just what it itself does.
- Install doxygen
doxygen doxygen_doc/doxygen_conf.txt-
chrome doxygen_doc/html/index.html(replacechromewith your browser of choice)
(This only needs to be done once.)
-
Fork the repository here on GitHub.
-
Clone your fork locally.
$ git clone https://github.com/YOUR_USERNAME/wakarimasen.git # Clones your fork of the repository into the current directory in terminal. -
Add this repository as a remote.
$ cd wakarimasen # Changes the active directory in the prompt to the newly cloned "wakarimasen" directory $ git remote add -f upstream https://github.com/Asialaide/wakarimasen.git # Assigns the original repository to a remote called "upstream"
-
Make sure you have your
masterbranch checked out.$ git checkout master -
Pull the changes from the
upstream/masterbranch.$ git pull --ff-only upstream master # Gets changes from the "master" branch on the "upstream" remote
- Note: If this gives you an error, it means you've committed directly to your local
masterbranch. Click here for instructions on how to fix this issue.
-
Update your
masterbranch, if you haven't already. -
For each new feature or bug fix, create a new branch.
$ git branch new_feature # Creates a new branch called "new_feature" $ git checkout new_feature # Makes "new_feature" the active branch -
Once you've committed some changes locally, you need to push them to your fork here on GitHub.
$ git push origin new_feature # Origin was automatically set to point to your fork when you cloned it -
Once you've finished working on your branch, and have committed and pushed all your changes, submit a pull request from your
new_featurebranch to this repository'smasterbranch.
- Note: Any new commits to the
new_featurebranch on GitHub will automatically be included in the pull request, so make sure to only commit related changes to the same branch.
- Mark pull requests that are still being worked on with [WIP] at the end of the title
- When a pull request is ready to be reviewed remove the [WIP]
- Mark pull requests that need commenting / testing by others with [CR]
These guidelines aren't essential, but they can make keeping things in order much easier.
Remote tracking branches allow you to easily stay in touch with this repository's master branch, as they automatically know which remote branch to get changes from.
$ git branch -vv
* master xxxx [origin/master] ....
new_feature xxxx ....
Here you can see we have two branches; master which is tracking origin/master, and new_feature which isn't tracking any branch. In practice, what this means is that git won't know where to get changes from.
$ git checkout new_feature
Switched to branch 'new_feature'
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
In order to easily pull changes from upstream/master into the new_feature branch, we can tell git which branch it should track. (You can even do this for your local master branch.)
$ git branch -u upstream/master new_feature
Branch new_feature set up to track remote branch master from upstream.
$ git pull
Updating xxxx..xxxx
....
You can also set the tracking information at the same time as creating the branch.
$ git branch new_feature_2 --track upstream/master
Branch new_feature_2 set up to track remote branch master from upstream.
-
Note: Although this makes it easier to pull from
upstream/master, it doesn't change anything with regards to pushing.git pushfails because you don't have permission to push toupstream/master.$ git push error: The requested URL returned error: 403 while accessing https://github.com/Asialaide/wakarimasen.git fatal: HTTP request failed $ git push origin .... To https://github.com/YOUR_USERNAME/wakarimasen.git xxxx..xxxx new_feature -> new_feature
####Why does git pull --ff-only result in an error?
If git pull --ff-only shows an error, it means that you've committed directly to your local master branch. To fix this, we create a new branch with these commits, find the point at which we diverged from upstream/master, and then reset master to that point.
$ git pull --ff-only upstream master
From https://github.com/Asialaide/wakarimasen
* branch master -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
$ git branch new_branch master # mark the current commit with a tmp branch
$ git merge-base master upstream/master
cc31d0... # the last commit before we committed directly to master
$ git reset --hard cc31d0....
HEAD is now at cc31d0... ...
Now that master has been cleaned up, we can easily pull from upstream/master, and then continue working on new_branch.
$ git pull --ff-only upstream master
# gets changes from the "upstream" remote for the matching branch, in this case "master"
$ git checkout new_branch