Project

General

Profile

RedmineGitTracking » History » Version 10

Toshi MARUYAMA, 2012-05-01 04:14
add *obsolete* and replace github mirror

1 1 John Goerzen
h1. Using Git to contribute to Redmine
2
3 10 Toshi MARUYAMA
*This wiki is obsolete*.
4
5 8 Mischa The Evil
{{>toc}}
6
7 1 John Goerzen
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.
8
9 10 Toshi MARUYAMA
*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/redmine/redmine is recommended for the latest development work.
10 1 John Goerzen
11 8 Mischa The Evil
If you were looking for Subversion instructions, they can be found on the [[Download|download]] and [[CheckingoutRedmine|checkout]] pages.
12 3 John Goerzen
13 7 Mischa The Evil
h2. Initialization
14
15
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.
16 1 John Goerzen
To start out, run these commands:
17
18
<pre>
19
git clone git://git.complete.org/branches/redmine-integration
20
cd redmine-integration
21
git config --add remote.origin.fetch +refs/remotes/svn/*:refs/remotes/svn/*
22
git fetch
23
</pre>
24
25
h2. Exploration
26
27
You can see all the branches that Git obtained for you:
28
29
<pre>
30
git branch -r | less
31
</pre>
32
33 7 Mischa The Evil
You'll see output like this (many lines omitted here):
34 1 John Goerzen
35 2 John Goerzen
<pre>
36 1 John Goerzen
  origin/HEAD
37
  origin/fb-bug-259-git
38
  origin/fb-bug-261-issue-redirect
39
  origin/fb-bug-641-context-done
40
  svn/git
41
  svn/issue_relations
42
  svn/mailing_lists
43
  svn/tags/0.6.3
44
  svn/tags/0.6.3@1011
45
  svn/time
46
  svn/trunk
47
  svn/wiki
48
</pre>
49
50 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.
51 1 John Goerzen
52
You'll base your work off these branches.
53
54 7 Mischa The Evil
h2. Starting Your Feature
55 1 John Goerzen
56 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.
57 2 John Goerzen
58 7 Mischa The Evil
You'll want to base your patch on svn trunk. So you'll set up a branch like so:
59 2 John Goerzen
60
<pre>
61
$ git branch my-feature svn/trunk
62
Branch my-feature set up to track remote branch refs/remotes/svn/trunk.
63
$ git checkout my-feature
64
</pre>
65
66 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.
67 2 John Goerzen
68
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.
69
70
You can run @git branch@ to see what branch you're on -- it'll have an asterisk next to it, like this:
71
72
<pre>
73
$ git branch
74
  master
75
* my-feature
76
</pre>
77
78 7 Mischa The Evil
h2. Working on your feature
79 1 John Goerzen
80
Now that you have made your branch, it's time start work.
81
82 3 John Goerzen
Here are some commands you may want to use:
83
84
|_.task|_.command|
85
|Commit outstanding changes|@git commit -a@|
86
|Add a new file to the repo|@git add filename@|
87
|Remove a file from the repo and working directory|@git rm filename@|
88 1 John Goerzen
|Rename a file in repo and working directory|@git mv oldname newname@|
89
|View history|@git log@|
90
|Get help|@git commandname --help@|
91 3 John Goerzen
92 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.
93 1 John Goerzen
94 7 Mischa The Evil
h2. Merging with trunk
95 4 John Goerzen
96 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:
97 4 John Goerzen
98 9 Lucas Panjer
<pre>
99 4 John Goerzen
git fetch
100
git rebase svn/trunk
101 9 Lucas Panjer
</pre>
102 4 John Goerzen
103 7 Mischa The Evil
h2. Submitting your Patch
104 4 John Goerzen
105 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.
106 4 John Goerzen
107 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:
108 4 John Goerzen
109 9 Lucas Panjer
<pre>
110 4 John Goerzen
git diff svn/trunk..HEAD > /tmp/feature.diff
111 9 Lucas Panjer
</pre>
112 4 John Goerzen
113 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.
114 5 John Goerzen
115 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.
116 5 John Goerzen
117 7 Mischa The Evil
h2. External Links
118 5 John Goerzen
119
* "Git homepage":http://www.git.or.cz/
120
* "5-Minute Git Guide":http://software.complete.org/site/wiki/GitGuide