Git notes

Here are some notes I find handy for using git.

§    Looking at stuff

§    Setup

§    Fixing stuff

§    Branches

§    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 immediately appear in the original working copy files.

Bill Harlan, 2009-2016


Return to parent directory.