RedmineGitTracking
Version 9 (Lucas Panjer, 2009-09-30 23:07)
| 1 | 1 | John Goerzen | h1. Using Git to contribute to Redmine |
|---|---|---|---|
| 2 | 1 | John Goerzen | |
| 3 | 8 | Mischa The Evil | {{>toc}} |
| 4 | 8 | Mischa The Evil | |
| 5 | 7 | Mischa The Evil | Redmine's source tree is stored in Subversion, and everything eventually feeds into there. Some who are comfortable using Git prefer to use it for its branching and merging features, and because you don't need to have SVN commit access to make commits. |
| 6 | 1 | John Goerzen | |
| 7 | 8 | Mischa The Evil | *Caution*: The git repository at complete.org isn't kept current, as of this writing the last change was done Mon, 8 Sep 2008. Cloning the "GitHub mirror":http://github.com/edavis10/redmine/tree/master is recommended for the latest development work. |
| 8 | 1 | John Goerzen | |
| 9 | 8 | Mischa The Evil | If you were looking for Subversion instructions, they can be found on the [[Download|download]] and [[CheckingoutRedmine|checkout]] pages. |
| 10 | 3 | John Goerzen | |
| 11 | 7 | Mischa The Evil | h2. Initialization |
| 12 | 7 | Mischa The Evil | |
| 13 | 7 | Mischa The Evil | If you don't yet have Git, see the 5-minute Git Guide in the links below for download information. You'll want a Git version of at least 1.5.x. |
| 14 | 1 | John Goerzen | To start out, run these commands: |
| 15 | 1 | John Goerzen | |
| 16 | 1 | John Goerzen | <pre> |
| 17 | 1 | John Goerzen | git clone git://git.complete.org/branches/redmine-integration |
| 18 | 1 | John Goerzen | cd redmine-integration |
| 19 | 1 | John Goerzen | git config --add remote.origin.fetch +refs/remotes/svn/*:refs/remotes/svn/* |
| 20 | 1 | John Goerzen | git fetch |
| 21 | 1 | John Goerzen | </pre> |
| 22 | 1 | John Goerzen | |
| 23 | 1 | John Goerzen | h2. Exploration |
| 24 | 1 | John Goerzen | |
| 25 | 1 | John Goerzen | You can see all the branches that Git obtained for you: |
| 26 | 1 | John Goerzen | |
| 27 | 1 | John Goerzen | <pre> |
| 28 | 1 | John Goerzen | git branch -r | less |
| 29 | 1 | John Goerzen | </pre> |
| 30 | 1 | John Goerzen | |
| 31 | 7 | Mischa The Evil | You'll see output like this (many lines omitted here): |
| 32 | 1 | John Goerzen | |
| 33 | 2 | John Goerzen | <pre> |
| 34 | 1 | John Goerzen | origin/HEAD |
| 35 | 1 | John Goerzen | origin/fb-bug-259-git |
| 36 | 1 | John Goerzen | origin/fb-bug-261-issue-redirect |
| 37 | 1 | John Goerzen | origin/fb-bug-641-context-done |
| 38 | 1 | John Goerzen | svn/git |
| 39 | 1 | John Goerzen | svn/issue_relations |
| 40 | 1 | John Goerzen | svn/mailing_lists |
| 41 | 1 | John Goerzen | svn/tags/0.6.3 |
| 42 | 1 | John Goerzen | svn/tags/0.6.3@1011 |
| 43 | 1 | John Goerzen | svn/time |
| 44 | 1 | John Goerzen | svn/trunk |
| 45 | 1 | John Goerzen | svn/wiki |
| 46 | 1 | John Goerzen | </pre> |
| 47 | 1 | John Goerzen | |
| 48 | 7 | Mischa The Evil | The "origin" branches are being maintained in Git (no corresponding Subversion branch). The svn branches are identical copies of the same branch in the Redmine Subversion repository. |
| 49 | 1 | John Goerzen | |
| 50 | 1 | John Goerzen | You'll base your work off these branches. |
| 51 | 1 | John Goerzen | |
| 52 | 7 | Mischa The Evil | h2. Starting Your Feature |
| 53 | 1 | John Goerzen | |
| 54 | 7 | Mischa The Evil | With git, branches are cheap and merges are easy, so you'll usually want to start a new branch for each feature you work on. A single branch will probably correspond to a single issue in Redmine when you submit the patch. |
| 55 | 2 | John Goerzen | |
| 56 | 7 | Mischa The Evil | You'll want to base your patch on svn trunk. So you'll set up a branch like so: |
| 57 | 2 | John Goerzen | |
| 58 | 2 | John Goerzen | <pre> |
| 59 | 2 | John Goerzen | $ git branch my-feature svn/trunk |
| 60 | 2 | John Goerzen | Branch my-feature set up to track remote branch refs/remotes/svn/trunk. |
| 61 | 2 | John Goerzen | $ git checkout my-feature |
| 62 | 2 | John Goerzen | </pre> |
| 63 | 2 | John Goerzen | |
| 64 | 7 | Mischa The Evil | The first line created a branch named @my-feature@, which will be based on svn/trunk. The second command checks out that branch, which means that your working copy is switched to it, and any commits you make will be posted to that branch. |
| 65 | 2 | John Goerzen | |
| 66 | 2 | John Goerzen | Note that the act of committing doesn't sent any patches to anyone else; as Git is distributed, commits are recorded locally only until you're ready to push them upstream. |
| 67 | 2 | John Goerzen | |
| 68 | 2 | John Goerzen | You can run @git branch@ to see what branch you're on -- it'll have an asterisk next to it, like this: |
| 69 | 2 | John Goerzen | |
| 70 | 2 | John Goerzen | <pre> |
| 71 | 2 | John Goerzen | $ git branch |
| 72 | 2 | John Goerzen | master |
| 73 | 2 | John Goerzen | * my-feature |
| 74 | 2 | John Goerzen | </pre> |
| 75 | 2 | John Goerzen | |
| 76 | 7 | Mischa The Evil | h2. Working on your feature |
| 77 | 1 | John Goerzen | |
| 78 | 1 | John Goerzen | Now that you have made your branch, it's time start work. |
| 79 | 1 | John Goerzen | |
| 80 | 3 | John Goerzen | Here are some commands you may want to use: |
| 81 | 3 | John Goerzen | |
| 82 | 3 | John Goerzen | |_.task|_.command| |
| 83 | 3 | John Goerzen | |Commit outstanding changes|@git commit -a@| |
| 84 | 3 | John Goerzen | |Add a new file to the repo|@git add filename@| |
| 85 | 3 | John Goerzen | |Remove a file from the repo and working directory|@git rm filename@| |
| 86 | 1 | John Goerzen | |Rename a file in repo and working directory|@git mv oldname newname@| |
| 87 | 1 | John Goerzen | |View history|@git log@| |
| 88 | 1 | John Goerzen | |Get help|@git commandname --help@| |
| 89 | 3 | John Goerzen | |
| 90 | 7 | Mischa The Evil | Note that @git command@ is the same as @git-command@. You can use @man git-command@ to see the manpage for any Git command. |
| 91 | 1 | John Goerzen | |
| 92 | 7 | Mischa The Evil | h2. Merging with trunk |
| 93 | 4 | John Goerzen | |
| 94 | 7 | Mischa The Evil | If you are working with your feature for awhile, you may find that Subversion has updated. Ideally you will make your eventual diff work with the latest trunk revision, so you'll want to make your patch work with that. To update your patches to apply on top of the latest trunk, do this: |
| 95 | 4 | John Goerzen | |
| 96 | 9 | Lucas Panjer | <pre> |
| 97 | 4 | John Goerzen | git fetch |
| 98 | 4 | John Goerzen | git rebase svn/trunk |
| 99 | 9 | Lucas Panjer | </pre> |
| 100 | 4 | John Goerzen | |
| 101 | 7 | Mischa The Evil | h2. Submitting your Patch |
| 102 | 4 | John Goerzen | |
| 103 | 7 | Mischa The Evil | When you're done working on your patch, make sure you have committed it to Git. Then you can generate diffs. |
| 104 | 4 | John Goerzen | |
| 105 | 7 | Mischa The Evil | You can generate one big diff, that includes all the changes you have made on the branch, even if they were made in multiple commits. Run this: |
| 106 | 4 | John Goerzen | |
| 107 | 9 | Lucas Panjer | <pre> |
| 108 | 4 | John Goerzen | git diff svn/trunk..HEAD > /tmp/feature.diff |
| 109 | 9 | Lucas Panjer | </pre> |
| 110 | 4 | John Goerzen | |
| 111 | 7 | Mischa The Evil | That means "calculate the difference between the trunk and the latest commit on this branch, and store it as a diff in /tmp/feature.diff". Then go to the redmine.org, create an issue, and attach /tmp/feature.diff to it. |
| 112 | 5 | John Goerzen | |
| 113 | 7 | Mischa The Evil | If you wish to submit one patch for each commit, just run @git format-patch svn/trunk@. You'll get one file generated for each commit, complete with the commit log. Then you'll want to attach each of these at redmine.org. Usually, though, you'll want the one big diff. |
| 114 | 5 | John Goerzen | |
| 115 | 7 | Mischa The Evil | h2. External Links |
| 116 | 5 | John Goerzen | |
| 117 | 5 | John Goerzen | * "Git homepage":http://www.git.or.cz/ |
| 118 | 5 | John Goerzen | * "5-Minute Git Guide":http://software.complete.org/site/wiki/GitGuide |