Git notes

Using Subversion as source control for personal files, I was finding it difficult to maintain contact with a single central repository. Git solves that problem nicely, and even plays well with Subversion.

Git commands are very similar to those of Subversion.

Mercurial solves the same problem, but with greatly reduced number of options [ Mercurial_notes.html ] . On the other hand, Git commands can be more puzzling; you may find yourself in situations that are difficult to reverse.

Mercurial is implemented in C with many Linux dependencies. It is supported on Windows only with Cygwin.

Here is a tutorial for SVN users:

http://git.or.cz/course/svn.html

Another fine tutorial:

http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html

http://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html

The best way to learn how it really works, however, is to read through the entire manual: http://www.kernel.org/pub/software/scm/git/docs/user-manual.html

§    Installation

The main site, with many more docs, is here:

http://git-scm.com/

Follow the installation instructions in the INSTALL file. Do not follow the usual Gnu procedure with ./configure though it may appear to work.

I found it necessary to download and install the asciidoc and docbook2x packages first, which have a Gnu type install.

I also needed the perl XML-SAX and XML-NamespaceSupport from CPAN.

§    Making a Subversion working copy into a Git respository

First check out a working copy of Subversion, and create a new git repository that shares the working copy:
svn co URL/trunk svnGitRepo
cd svnGitRepo
git init
cat > .gitignore <<EOF
.svn/
EOF
git add .
git status
git commit -m "imported from svn"
git log

Then I can make a copy of this repository to a detachable disk.
cd /media/USBDISK
git clone /path/svnGitRepo gitOnly # locally

Here's a sample remote path:
git clone ssh://host/~/path/svnGitRepo gitOnly  # remote

Assume that the git-only copy is modified offsite.
cd /media/USBDISK/gitOnly
echo foo > testfile
git add testfile
git commit -m test
git log

Later that detachable disk is reconnected and you want the changes merged with the latest version of the SVN repository.

First update the original SVN working copy, and save the changes into that Git repository.
cd $HOME/svnGitRepo
svn up
git commit -m "updated from SVN"

Thet get the updates from the offsite copy and check them into SVN.
cd $HOME/svnGitRepo
git pull /media/USBDISK/gitOnly
svn commit -m "updated from Git"

Then merge those SVN changes into the offsite Git copy:
cd /media/USBDISK/gitOnly
git pull

If the automatic merge fails, then edit the file however you want. Then, add the conflicted file again, to stage it for commitment:
git add path/to/merged_file
git commit -m "merged SVN updates"

You can also push commited changes from the client back to the original repository, but I discourage it. Your changes will not appear in the original working copy until you git reset --hard, which also discards any local edits.

This sort of behavior will baffle you until you read the entire manual http://www.kernel.org/pub/software/scm/git/docs/user-manual.html

Bill Harlan, January, 2009


Return to parent directory.