This document describes how developers should use Git, our SCM.
ETA of git migration is here: https://cwiki.apache.org/confluence/display/MAVEN/Git+Migration
Commits should be focused on one issue at a time, because that makes it easier for others to review the commit.
A commit message should use this template:
[ISSUE-1] <<Summary field from JIRA>> Submitted by: <<Name of non-committer>> o Comments
[MNG-1456] Added the foo to the bar Submitted by: Baz Bazman o Applied without change
By default, the committer should apply the patch without any major modifications. In a second step, the committer could apply any changes as usual.
$ git commit --amend -m "new comment"
Workflow for svn folks is something like :
$ git pull $ hack hack hack $ git push // fails, because someone else has already pushed to master $ git pull // this creates some merges $ git push
A more quiet workflow :
$ git pull $ hack hack hack $ git push // fails, because someone else has already pushed to master $ git fetch // this moves 'origin/master' $ git rebase origin/master // this reapplies your local changes on top of origin/master $ git push
If you've done a chunk of work and you would like ditch your changes and start from scratch use this command to revert to the original checkout:
$ git checkout .
This checkout is typical for highly experienced git users, and may serve as inspiration for others; as usual the best way to learn is by doing. Sample shown for maven-surefire
Go to https://github.com/apache/maven-surefire and fork surefire to your own github account.
Starting with nothing (no existing clone)
git clone https://github.com/<youraccount>/maven-surefire.git git remote add apache https://git-wip-us.apache.org/repos/asf/maven-surefire.git git remote add asfgithub https://github.com/apache/maven-surefire.git git config --add remote.asfgithub.fetch "+refs/pull/*/head:refs/remotes/asfgithub/pr/*" git fetch --all
(You may consider adding --global to the git config statement above to always fetch pull requests for any remote named "asfgithub")
In this setup, running "git push" will normally push to your personal github account. Furthermore, all pull requests from github are also fetched to your local clone, use
to try to make some sense of it all. This is an important command to understand! (gitk may need to be installed additionally)
If you're working on the master branch, you can do stuff like this:
git push # your github account git push apache # the authorative apache repo
Using your github account as a storage for half-finished work is excellent if you switch between multiple computers, always push to github before leaving your current computer and start by pulling at the next computer.
To merge a pull request
git merge pr/10 # merge pull request number 10 from asf@github into master git push apache # upload to apache
Or if you're comfortable with rebasing;
git checkout pr/10 git rebase apache/master git push apache