Table of Contents |
---|
This page is meant to document the various steps to working with git to contribute or review Kafka code. There are probably a lot of bugs in these steps or possible better recipes, so help make this page better.
...
This is the simple workflow and will work well for small features development for people who don't have direct access to check in to the Apache repository. Let's assume you are working on a feature or bug called, xyz:
1. Checkout a new repository:
...
Code Block |
---|
git fetch
git rebase remotes/origin/trunk
|
5. Make a patch containing your work and upload it to JIRA:
...
This assumes you already have a copy of the repository.
1. Make sure your code is up-to-date:
...
Code Block |
---|
git push origin trunk |
Simple
...
Commiter Workflow
If you have commit access on the apache repository then you will not be applying patches in the manner described in the reviewer workflow. Instead, once your patch has been reviewed you will check it in yourself directly from your feature branch:
1. Merge the change to trunkCreate a branch to work on:
Code Block |
---|
git fetch git checkout -b xyz remotes/origin/trunk |
2. Implement the feature.
3. Rebase:
Code Block |
---|
git merge xyzrebase remotes/origin/trunk |
34. Validate the change by running tests, checking the diff, etc.
3Post the change to JIRA and get it reviewed.
5. Push the change back to the official Apache repository
Code Block |
---|
git push origin trunk |
...
Apache doesn't seem to provide a place to stash your work-in-progress branches or provide some of the nice social features github has. This can be a problem for larger features. Here are instructions for using github as a place to stash your work in progress changes.
Setting Up
1. Checkout As in the other workflows begin by checking out kafka (if you haven't already) onto your local machine:
Code Block |
---|
git clone https://git-wip-us.apache.org/repos/asf/kafka.git kafka |
This sets up the remote alias "origin" automatically which refers back to the Apache repo.
2. Create a new github repository on your github account to use for stashing changes. There are various ways to do this, I just forked the apache/kafka repo (https://github.com/apache/kafka) which creates a repo https://github.com/jkreps/kafka (where jkreps would be your user name).
3. Add an alias on your local repository to github to avoid typing:
Code Block |
---|
git remotes add github https://github.com/<your_user>/kafka.git |
Now you can push either to origin or to github.
Doing Work
1. You can create a branch named xyz in your local repository and check it out
Code Block |
---|
git checkout -b xyz remotes/origin/trunk |
2. To set up a second machine to work on you can clone the github url.
3. To save your branch to your github repo do
Code Block |
---|
git push github xyz |
3. Maybe you need to work from multiple machines. To update your other machine with changes you have pushed to github 4. To pull these changes onto the other machine where you have a copy of the repository you can do:
Code Block |
---|
git fetch github git checkout xyz git merge remotes/github/xyz |
Review and pushing changes back to Apache works just as before.