Changes between Version 8 and Version 9 of GitMirror

Show
Ignore:
Timestamp:
02/26/09 16:22:17 (4 years ago)
Author:
pv
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitMirror

    v8 v9  
    1 There are automatically updated git mirrors of Numpy (and Scipy) on github: 
     1There are automatically updated git mirrors of Numpy (and Scipy) available: 
    22 
    33  - http://github.com/pv/numpy-svn 
    44  - http://github.com/pv/scipy-svn 
    55 
    6 One can also be found here: 
    7  
     6You can use these to make developing contributions to Numpy and Scipy easier. 
     7An example workflow is discussed on this page. 
     8 
     9There are also several developer's work repositories there, for example: 
     10 
     11  - http://github.com/pv/scipy-work 
    812  - http://github.com/cournape/numpy 
    913 
    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: 
     14You may also find Git's documentation useful: 
     15 
     16  - http://git-scm.com/documentation 
     17 
     18There 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 
     24You need to clone the Git mirror of Scipy's SVN repository first. 
     25This needs to be done only once. 
     26{{{ 
     27git clone git://github.com/pv/scipy-svn.git scipy.git 
     28}}} 
     29This will take some time, as the repository (ca. 30 MB) contains Scipy's whole history. 
     30 
     31Then, get the SVN branch pointers. First, edit `scipy.git/.git/config` and change 
     32the `remote "origin"` section to look like this: 
    2633{{{ 
    2734[remote "origin"] 
    28         url = git://github.com/pv/numpy-svn.git 
     35        url = git://github.com/pv/scipy-svn.git 
    2936        fetch = +refs/remotes/*:refs/remotes/* 
    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}}} 
     38ie. change `heads` to `remotes` and `origin` to `svn`. Then run 
     39{{{ 
     40git fetch 
     41}}} 
     42`XXX: this is mildly ugly, we can investigate if it's possible to streamline this` 
     43 
     44Now you can do 
     45{{{ 
     46git log trunk 
     47}}} 
     48to view the commit log of Scipy's trunk. Or, list branches and tags in SVN: 
     49{{{ 
     50git branch -r 
     51}}} 
     52 
     53== Initializing git-svn == 
     54 
     55This is optional, but needs to be done if you want to use git-svn 
     56to commit your changes back to SVN. 
     57{{{ 
     58git-svn init -s http://svn.scipy.org/svn/scipy 
     59git-svn rebase -l 
     60}}} 
     61This should be very fast. 
    6262 
    6363= Using the git clone = 
     
    6565== Create a branch == 
    6666 
    67 There is one rule to always remember: NEVER WORK ON A SVN BRANCH DIRECTLY, ALWAYS ON A BRANCH MADE FROM IT! 
     67There is one rule to always remember: 
     68'''never work on a remote (eg. SVN) branch directly, always on a branch made from it!''' 
     69 
    6870Concretely, if you want to work on the trunk 
    69  
    7071{{{ 
    7172# Make a branch 'work' based on trunk, and switch to it 
    7273git checkout -b work trunk 
    7374}}} 
    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: 
     75You can list available branches with 
     76{{{ 
     77git branch       # <- your branches 
     78git branch -r    # <- remote branches 
     79}}} 
     80 
     81== Edit and commit == 
     82 
     83For this point, things function as explained in the Git tutorial: http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html 
     84 
     85Commands typically needed: 
     86{{{ 
     87git add FILES       # add new files 
     88git commit FILES    # commit. If you don't supply files, supply -a to commit everything 
     89}}} 
     90 
     91== Staying abreast SVN == 
     92 
     93To fetch new items from the SVN mirror, just do 
     94{{{ 
     95git fetch 
     96}}} 
     97 
     98Then, you'll need to merge your changes with those in trunk. 
     99Two options: rebase or merge. 
     100 
     101If you haven't published your changes, you can just use rebase: 
     102{{{ 
     103git rebase trunk 
     104}}} 
     105If there are conflicts, it will ask you to resolve them. After 
     106all is done, your commits will lie on top of those in SVN. 
     107Note that if one of your commits exactly matches changes made in SVN, 
     108it will silently disappear in rebasing. 
     109 
     110An alternative is merging, which does not rewrite history, 
     111{{{ 
     112git 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 
     118This should work similarly as in standard Git, but let's briefly mention some main points: 
     119 
     120== Publishing your branches == 
     121 
     122For example http://github.com offers free space for publishing your work on Open-source projects. 
     123It's one of the most prominent providers, so we concentrate on it for now. 
     124 
     125For github, you can fork the scipy-svn repository via the web interface, so that you don't need 
     126to transfer a lot of data the first time. 
     127Note that you need to have a SSH private key to upload. Check the documentation 
     128 
     129    http://github.com/guides/home 
     130 
     131for how to get started with this. 
     132 
     133After that, tell git about your github account and the repository there 
     134{{{ 
     135git remote add github git@github.com:pv/scipy-work.git 
     136}}} 
     137The address is specific to your account, so change it accordingly. 
     138 
     139Pushing your branch there: 
     140{{{ 
     141git push github BRANCHNAME 
     142}}} 
     143 
     144 
     145== Viewing other people's changes == 
     146 
     147First, tell Git about someone's branch: 
     148{{{ 
     149git remote add pauli git://github.com/pv/scipy-work.git 
     150git fetch pauli 
     151git remote show pauli 
     152}}} 
     153 
     154Switch the working tree to it: 
     155{{{ 
     156git checkout pauli/ticket-503-special-iv-fix 
     157}}} 
     158 
     159Examine what was done there: 
     160{{{ 
     161git log trunk.. 
     162git diff trunk 
     163git show bb21c 
     164git show 7f738 
     165}}} 
     166 
     167If you want to hack on it yourself, again create a branch of your own: 
     168{{{ 
     169git 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 
     179If you configured git-svn as instructed above, you can interface directly to SVN. 
     180 
     181== Fetching items directly from SVN == 
     182 
     183You can update your repository directly from SVN. It will still stay compatible with the SVN mirror even if you do this. 
     184{{{ 
     185git svn fetch 
     186}}} 
     187 
     188== Committing to SVN == 
     189 
     190Commit back to the scipy svn repository with git svn dcommit: 
    78191{{{ 
    79192git svn dcommit 
    80193}}} 
    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): 
     194Note that this will create one commit for each one you have in Git. 
     195 
     196If you want to compress things to more compact form, you can use rebase 
     197{{{ 
     198git rebase -i HASH 
     199}}} 
     200where HASH is a commit preceding the one, starting from which you want to 
     201compress history. This interactive rebasing allows you e.g. to edit commit 
     202messages, reorder commits (may cause conflicts), or squash several commits 
     203into a single one.  
     204 
     205It may be wise to do create a separate branch for working on this 
     206in case you mess up. 
     207 
     208Before actually committing, it is also a good idea to check whether you are 
     209committing where you think you are committing (with the dry run option of 
     210`git svn dcommit`): 
    83211{{{ 
    84212git svn dcommit -n 
    85213}}} 
    86  
    87 == Updating from numpy svn repository == 
    88  
    89 Use the rebase command. For example, updating the trunk is a matter of: 
    90 {{{ 
    91 git checkout trunk 
    92 git svn rebase -l 
    93 }}}