Skip to content
Dominik Bamberger edited this page Mar 28, 2014 · 18 revisions

Table of Contents

Workflow

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

# optionally push the changes to GitHub (to enable co-workers to contribute).
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

# 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

# fork the project on GitHub.

# checkout the forked 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
# NOTE: depending on your setup, you might want to add a remote for upstream and pull from there.
# future versions of git-review will provide a command to set this up for you automatically.
git checkout master
git pull
git rebase master new_feature

# optionally push the changes to GitHub (to enable co-workers to contribute).
git push origin new_feature

# initiate code review by sending a pull request to the upstream project.
git review create --upsteam

Alternatively, you can also just work on master and let git-review create the necessary branches for you. Once you call ```git review create --upstream``` 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 forked 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 --upstream

For the upstream repository, reviewing your pull request is the same as before.

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. Additionally, please create any potential pull requests against the "development" branch.

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.