| 10 | | I won't talk about how to use git, only some points to keep in mind when using the mirror. There is a lot of resources to learn git on the web. |
| 11 | | |
| 12 | | = Download the git = |
| 13 | | |
| 14 | | Cloning the repository is straightforward: |
| 15 | | {{{ |
| 16 | | git clone http://github.com/pv/numpy-svn.git |
| 17 | | }}} |
| 18 | | |
| 19 | | = Importing svn meta-data = |
| 20 | | |
| 21 | | Unfortunately, the clone command of git does not copy the svn metadata by default. To do so, you have to do the following for each clone: |
| 22 | | |
| 23 | | == Get the SVN branches == |
| 24 | | |
| 25 | | Edit .git/config to look something like this: |
| | 14 | You may also find Git's documentation useful: |
| | 15 | |
| | 16 | - http://git-scm.com/documentation |
| | 17 | |
| | 18 | There are also a lot of other resources to learn git on the web; this text concentrates more on using this specific SVN mirror. |
| | 19 | |
| | 20 | = Preparations = |
| | 21 | |
| | 22 | == Clone the Git mirror == |
| | 23 | |
| | 24 | You need to clone the Git mirror of Scipy's SVN repository first. |
| | 25 | This needs to be done only once. |
| | 26 | {{{ |
| | 27 | git clone git://github.com/pv/scipy-svn.git scipy.git |
| | 28 | }}} |
| | 29 | This will take some time, as the repository (ca. 30 MB) contains Scipy's whole history. |
| | 30 | |
| | 31 | Then, get the SVN branch pointers. First, edit `scipy.git/.git/config` and change |
| | 32 | the `remote "origin"` section to look like this: |
| 30 | | [branch "master"] |
| 31 | | remote = origin |
| 32 | | merge = refs/remotes/trunk |
| 33 | | }}} |
| 34 | | This ensures that you get the most recent SVN branch pointers when you run ''git fetch''. |
| 35 | | |
| 36 | | Alternatively, execute the following command to get them only once: |
| 37 | | {{{ |
| 38 | | git fetch git://github.com/pv/numpy-svn.git +refs/remotes/*:refs/remotes/* |
| 39 | | }}} |
| 40 | | This will tell git to download all the svn branch/tags info available on the git mirror just this time. |
| 41 | | |
| 42 | | == Configure git-svn == |
| 43 | | |
| 44 | | If you want to commit back to SVN, or to get changes directly from SVN, you need to configure git-svn for the clone: |
| 45 | | |
| 46 | | Edit your .git/config, and add the follwing: |
| 47 | | {{{ |
| 48 | | [svn-remote "svn"] |
| 49 | | url = http://svn.scipy.org/svn/numpy |
| 50 | | fetch = trunk:refs/remotes/trunk |
| 51 | | branches = branches/*:refs/remotes/* |
| 52 | | tags = tags/*:refs/remotes/tags/* |
| 53 | | }}} |
| 54 | | This tells git-svn where to get svn meta-data. |
| 55 | | |
| 56 | | To update the svn metadata, run: |
| 57 | | {{{ |
| 58 | | git checkout master && git svn rebase -l |
| 59 | | }}} |
| 60 | | This should be reasonably fast. |
| 61 | | |
| | 37 | }}} |
| | 38 | ie. change `heads` to `remotes` and `origin` to `svn`. Then run |
| | 39 | {{{ |
| | 40 | git fetch |
| | 41 | }}} |
| | 42 | `XXX: this is mildly ugly, we can investigate if it's possible to streamline this` |
| | 43 | |
| | 44 | Now you can do |
| | 45 | {{{ |
| | 46 | git log trunk |
| | 47 | }}} |
| | 48 | to view the commit log of Scipy's trunk. Or, list branches and tags in SVN: |
| | 49 | {{{ |
| | 50 | git branch -r |
| | 51 | }}} |
| | 52 | |
| | 53 | == Initializing git-svn == |
| | 54 | |
| | 55 | This is optional, but needs to be done if you want to use git-svn |
| | 56 | to commit your changes back to SVN. |
| | 57 | {{{ |
| | 58 | git-svn init -s http://svn.scipy.org/svn/scipy |
| | 59 | git-svn rebase -l |
| | 60 | }}} |
| | 61 | This should be very fast. |
| 74 | | |
| 75 | | == Committing to svn == |
| 76 | | |
| 77 | | If you have set up git-svn as instructed above, you can commit back to the scipy svn repository with git svn dcommit: |
| | 75 | You can list available branches with |
| | 76 | {{{ |
| | 77 | git branch # <- your branches |
| | 78 | git branch -r # <- remote branches |
| | 79 | }}} |
| | 80 | |
| | 81 | == Edit and commit == |
| | 82 | |
| | 83 | For this point, things function as explained in the Git tutorial: http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html |
| | 84 | |
| | 85 | Commands typically needed: |
| | 86 | {{{ |
| | 87 | git add FILES # add new files |
| | 88 | git commit FILES # commit. If you don't supply files, supply -a to commit everything |
| | 89 | }}} |
| | 90 | |
| | 91 | == Staying abreast SVN == |
| | 92 | |
| | 93 | To fetch new items from the SVN mirror, just do |
| | 94 | {{{ |
| | 95 | git fetch |
| | 96 | }}} |
| | 97 | |
| | 98 | Then, you'll need to merge your changes with those in trunk. |
| | 99 | Two options: rebase or merge. |
| | 100 | |
| | 101 | If you haven't published your changes, you can just use rebase: |
| | 102 | {{{ |
| | 103 | git rebase trunk |
| | 104 | }}} |
| | 105 | If there are conflicts, it will ask you to resolve them. After |
| | 106 | all is done, your commits will lie on top of those in SVN. |
| | 107 | Note that if one of your commits exactly matches changes made in SVN, |
| | 108 | it will silently disappear in rebasing. |
| | 109 | |
| | 110 | An alternative is merging, which does not rewrite history, |
| | 111 | {{{ |
| | 112 | git merge trunk |
| | 113 | }}} |
| | 114 | `XXX: but committing changes back using git-svn may be more hairy if there are merges? Also, you get duplicate commits, since SVN cannot contain merge commits` |
| | 115 | |
| | 116 | = Collaboration via git = |
| | 117 | |
| | 118 | This should work similarly as in standard Git, but let's briefly mention some main points: |
| | 119 | |
| | 120 | == Publishing your branches == |
| | 121 | |
| | 122 | For example http://github.com offers free space for publishing your work on Open-source projects. |
| | 123 | It's one of the most prominent providers, so we concentrate on it for now. |
| | 124 | |
| | 125 | For github, you can fork the scipy-svn repository via the web interface, so that you don't need |
| | 126 | to transfer a lot of data the first time. |
| | 127 | Note that you need to have a SSH private key to upload. Check the documentation |
| | 128 | |
| | 129 | http://github.com/guides/home |
| | 130 | |
| | 131 | for how to get started with this. |
| | 132 | |
| | 133 | After that, tell git about your github account and the repository there |
| | 134 | {{{ |
| | 135 | git remote add github git@github.com:pv/scipy-work.git |
| | 136 | }}} |
| | 137 | The address is specific to your account, so change it accordingly. |
| | 138 | |
| | 139 | Pushing your branch there: |
| | 140 | {{{ |
| | 141 | git push github BRANCHNAME |
| | 142 | }}} |
| | 143 | |
| | 144 | |
| | 145 | == Viewing other people's changes == |
| | 146 | |
| | 147 | First, tell Git about someone's branch: |
| | 148 | {{{ |
| | 149 | git remote add pauli git://github.com/pv/scipy-work.git |
| | 150 | git fetch pauli |
| | 151 | git remote show pauli |
| | 152 | }}} |
| | 153 | |
| | 154 | Switch the working tree to it: |
| | 155 | {{{ |
| | 156 | git checkout pauli/ticket-503-special-iv-fix |
| | 157 | }}} |
| | 158 | |
| | 159 | Examine what was done there: |
| | 160 | {{{ |
| | 161 | git log trunk.. |
| | 162 | git diff trunk |
| | 163 | git show bb21c |
| | 164 | git show 7f738 |
| | 165 | }}} |
| | 166 | |
| | 167 | If you want to hack on it yourself, again create a branch of your own: |
| | 168 | {{{ |
| | 169 | git checkout -b ticket-503-special-iv-fix pauli/ticket-503-special-iv-fix |
| | 170 | }}} |
| | 171 | |
| | 172 | == Dealing with changes in SVN == |
| | 173 | |
| | 174 | `XXX: todo, find out and explain what to do if you have made changes to someone's stuff, and he/she has rebased against SVN in the meantime` |
| | 175 | |
| | 176 | |
| | 177 | = Dealing directly with SVN = |
| | 178 | |
| | 179 | If you configured git-svn as instructed above, you can interface directly to SVN. |
| | 180 | |
| | 181 | == Fetching items directly from SVN == |
| | 182 | |
| | 183 | You can update your repository directly from SVN. It will still stay compatible with the SVN mirror even if you do this. |
| | 184 | {{{ |
| | 185 | git svn fetch |
| | 186 | }}} |
| | 187 | |
| | 188 | == Committing to SVN == |
| | 189 | |
| | 190 | Commit back to the scipy svn repository with git svn dcommit: |
| 81 | | |
| 82 | | Before actually committing, it is a good idea to check whether you are committing where you think you are committing (with the dry run option of git svn dcommit): |
| | 194 | Note that this will create one commit for each one you have in Git. |
| | 195 | |
| | 196 | If you want to compress things to more compact form, you can use rebase |
| | 197 | {{{ |
| | 198 | git rebase -i HASH |
| | 199 | }}} |
| | 200 | where HASH is a commit preceding the one, starting from which you want to |
| | 201 | compress history. This interactive rebasing allows you e.g. to edit commit |
| | 202 | messages, reorder commits (may cause conflicts), or squash several commits |
| | 203 | into a single one. |
| | 204 | |
| | 205 | It may be wise to do create a separate branch for working on this |
| | 206 | in case you mess up. |
| | 207 | |
| | 208 | Before actually committing, it is also a good idea to check whether you are |
| | 209 | committing where you think you are committing (with the dry run option of |
| | 210 | `git svn dcommit`): |