Project

General

Profile

RedmineGitTracking » History » Version 6

Eric Davis, 2008-08-22 08:02
Adding disclaimer to the top of the page since complete.org's repository isn't current. This page will need a rewrite soon.

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