Skip to content
b4mboo edited this page Jun 30, 2012 · 18 revisions

Table of Contents

Working with GitHub

First you need to install the gem.

gem install git-review

Then you need to configure your .gitconfig:

[github]
  login = your_github_login
  password = your_github_password

Branches of the same repository

This assumes that all developers have write access to the project repository and therefore it is suitable for smaller projects/teams. The features, bugfixes... are implemented in separate branches, the code review is done by pull requests from branches to the master.

# checkout the project
git clone [email protected]:user_name/repository_name.git

# create a new feature branch
git review prepare

# iteratively work on the feature, commit small parts
<change the code>
git add
git commit

# integrate latest changes from the master
git checkout master
git pull
git rebase master new_feature

# push the changes to GitHub
git push origin new_feature

# initiate code review by sending a pull request
git review create

Alternatively, you can also just work on master and let git-review create the necessary branches for you. Once you call ```git review create``` all commits that have not yet been pushed to remote will be moved to a new branch. The only thing you'll have to do is provide a name for that branch.

# checkout the project
git clone [email protected]:user_name/repository_name.git

# iteratively work on the feature, commit small parts
<change the code>
git add
git commit

# integrate latest changes from the master
git pull

# initiate code review by sending a pull request
git review create

Now one of your co-workers should review your code:

# get a list of all open pull requests.
git review list

# review a specific pull request
git review show ID --full

# to show the pull request in the browser (and be able to add comments)
git review browse ID

# get a local copy of the code
git review checkout ID --branch

# add an approving comment
git review approve ID

# decline patches and close request
git review close ID

# accept pull request and merge it
git review merge ID
git push

Once your code has been merged, you can delete obsolete branches:

# remove both local and remote branch for that review
git review clean ID

# remove all obsolete branches
git review clean --all

Different forks of a project

This is not yet implemented in git-review, but is a planned feature for future releases of the tool.

Until then you'll have to use the UI that GitHub provides. For more information on forking and submitting pull requests, please refer to the GitHub help: http://help.github.com/fork-a-repo, http://help.github.com/send-pull-requests/

Hints

Overriding the default target branch (= master)

If you want to use a branch other than master to merge to, you can do so by setting an ENV variable.

TARGET_BRANCH=develop git review merge 42
Alternatively you can set that variable globally, of course. Thanks go to to swalberg for this nifty little feature.

TODOs

There are still a couple of TODOs on the list. If you want to contribute, feel free to work on one of these. However, it would be nice if you could tell me about it, such that we don't duplicate our work.

Check out this repo's issues section if you want to know the details of what is currently worked on or add some issues you found yourself.

Clone this wiki locally