GIT: Contributing to a project
Full title of this page if any
[Fork the repo](http://help.github.com/fork-a-repo) on which you're working, clone your forked repo to your local computer, and set up the upstream remote:
git clone git://github.com/YourGitHubUserName/repo.git git remote add upstream https://github.com/E-Health/repo.git
- Checkout out a new local branch based on your master and update it to the latest. The convention is to name the branch after the current ticket, e.g. TRUNK-123:
git checkout -b TRUNK-123 master git clean -df git pull --rebase upstream master
- Please keep your code clean. Name your branch after the JIRA issue or other description of the work being done. If you find another bug, you want to fix while being in a new branch, please fix it in a separated branch instead.
- Push the branch to your fork. Treat it as a backup.
git push origin TRUNK-123
* Adhere to common conventions you see in the existing code * Include tests, and ensure they pass
- Commit. For every commit please write a short (max 72 characters) summary in the first line followed with a blank line and then more detailed descriptions of the change. Use markdown syntax for simple styling. Please include any JIRA issue numbers in your summary.
git commit -m "TRUNK-123: Put change summary here (can be a ticket title)"
NEVER leave the commit message blank! Provide a detailed, clear, and complete description of your commit!
- If you do want to squash several commits together, you can use git rebase -i. If you're on branch topical_xFeature, you would run git rebase -i master. This will open an editor window, with a bunch of commits listed prefixed by pick. You can change all but the first to squash, which will tell Git to keep all of those changes, but squash them into the first commit. After you've done that, check out master and merge in your feature branch:
git checkout topical_xFeature git rebase -i master git checkout master git merge topical_xFeature
Alternatively, if you just want to squash everything in topical_xFeature into master, you could just do the following:
git checkout master git merge --squash topical_xFeature git commit
- Issue a Pull Request. Before submitting a pull request, update your branch to the latest code.
git pull --rebase upstream master
- If you have made many commits, we ask you to squash them into atomic units of work. Most of tickets should have one commit only, especially bug fixes, which makes them easier to back port.
git checkout master git pull --rebase upstream master git checkout TRUNK-123 git rebase -i master
- Push changes to your fork:
git push -f