[phobos] [dmd-internals] svn-->git migration

Jason Evans jasone at canonware.com
Sun Jan 23 19:32:38 PST 2011


On 01/23/2011 06:57 PM, Andrei Alexandrescu wrote:
> Say I have a change to make to one file in phobos 2 to get
> started. Could you please summarize what steps I need to take?

Let's suppose we want to update the README.txt in druntime, which 
currently refers to dsource.org.  First we need a git repository to work 
in.  Take a look at the following web page to get the appropriate ssh 
location.

   https://github.com/D-Programming-Language/druntime

Clone the repository.

   $ git clone git at github.com:D-Programming-Language/druntime.git
   $ cd druntime

Create a working branch, based on the master branch.  (I won't get much 
into branch management in this email.)

   $ git checkout -b update-README
   Switched to a new branch 'update-README'

Edit README.txt, then verify the diff.

   $ git diff
   diff --git a/README.txt b/README.txt
   index d0ae645..9183765 100644
   --- a/README.txt
   +++ b/README.txt
   @@ -1,5 +1,5 @@
    The source code repository for Druntime is:
   -http://dsource.org/projects/druntime
   +https://github.com/D-Programming-Language/druntime

    Druntime is the minimum library required to support the D programming
    language. It includes the system code required to support the garbage

Add README.txt to the staging index.

   $ git status
   # On branch update-README
   # Changed but not updated:
   #   (use "git add <file>..." to update what will be committed)
   #   (use "git checkout -- <file>..." to discard changes in working 
directory)
   #
   #       modified:   README.txt
   #
   no changes added to commit (use "git add" and/or "git commit -a")
   $ git add README.txt
   $ git diff
   $ git status
   # On branch update-README
   # Changes to be committed:
   #   (use "git reset HEAD <file>..." to unstage)
   #
   #       modified:   README.txt
   #

Commit to working branch.

   $ git commit -m "Update URL."
   [update-README 1fbddd4] Update URL.
    1 files changed, 1 insertions(+), 1 deletions(-)

Check out master branch and merge.  (If someone else had committed to 
master in the meanwhile, we would want to do a dance to "rebase" our 
working branch, but let's ignore that for now.)

   $ git checkout master
   Switched to branch 'master'
   $ git merge update-README
   Updating 559df80..1fbddd4
   Fast-forward
    README.txt |    2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

Now let's push the change to the master repository, and finally delete 
our working branch.

   $ git push origin master
   Counting objects: 5, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (3/3), done.
   Writing objects: 100% (3/3), 330 bytes, done.
   Total 3 (delta 2), reused 0 (delta 0)
   To git at github.com:D-Programming-Language/druntime.git
      559df80..1fbddd4  master -> master
   $ git branch -d update-README
   Deleted branch update-README (was 1fbddd4).

The above example has several steps in it that can be skipped for such a 
simple change, but for more involved changes, this work flow is the 
foundation.  git is a complex tool, but the underlying concepts are 
coherent, consistent, and straightforward.  Learn those concepts well 
and you will be largely able to infer what git is capable of.

Thanks,
Jason


More information about the phobos mailing list