Table of Contents

Subversion

Quickstart

$ cd /var/svn
$ svnadmin create repos
$ ls repos
conf/ dav/ db/ format hooks/ locks/ README.txt

suppose we have a directory:

/tmp/
   myproject/
      branches/
      tags/
      trunk/
         foo.c
         bar.c
         Makefile
         …

import to repo:

$ svn import /tmp/myproject file:///var/svn/repos/myproject \
      -m "initial import"
Adding         /tmp/myproject/branches
Adding         /tmp/myproject/tags
Adding         /tmp/myproject/trunk
Adding         /tmp/myproject/trunk/foo.c
Adding         /tmp/myproject/trunk/bar.c
Adding         /tmp/myproject/trunk/Makefile
…
Committed revision 1.

Typical Work Cycle

  1. Update your working copy: svn update
  2. Make your changes.
    • svn add
    • svn delete
    • svn copy
    • svn move
  3. Review your changes
    • svn status --verbose(-v) --show-updates(-u)
    • svn diff (> patch)
  4. Fix your mistackes
    • svn revert
  5. Resolve any conflicts (merge others’ changes)
    • svn update
    • svn resolve
  6. Publish (commit) your changes: svn commit

Branching and tagging

Subversion uses the inter-file branching model to implement branches and tagging. A branch is a separate line of development. Tagging refers to labeling the repository at a certain point in time so that it can be eaily found in the future. The only difference between branches and tags is how they are used.

A new branch or tag is set up by using the svn copy command, which should be used in place of the native operating system mechanism. The copied directory is linked to the original in the repository to preserve its history, and the copy takes very little extra space in the repository.

All the versions in each branch maintain the history of the file up to the point of the copy, plus any changes made since. One can merge changes back into the trunk or between branches.

Layers

  • Fs
    • The lowest lavel
    • implements the versioned filsystem which stores the user data
    • two-dimensional
      • Path (regular path of Unix-like OS filesystem)
      • Revision
  • Repos
    • Concerned with the repository built up around the filesystem
  • mod_dav_svn
    • provides WebDAV/Delta-V access through Apache 2
  • Ra (Repository Access)
    • handles “repository access”, both local and remote
    • e.g.
      • file:///path/ for local access
      • http://host/path/ or https://host/path/ for WebDav access
      • svn://host/path/ or svn+ssh://host/path/ for the SVN protocol
  • Client, Wc
    • The highest level
    • abstracts repository access and provides common client tasks
    • Subversion cilents use the Wc library to manage the local working copy

Mercurial-SCM

Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface.

Configuration

~/.hgrc

[ui]
username = Will D. Thomas <will_d_thomas@icloud.com>
[extensions]
rebase=
color=

/project/.hg/hgrc

[paths]
default = ssh://vcssh@phabricator.intern.oxnz.io/diffusion/17/platformz
[hooks]
pretxcommit = .hg/hooks.unittest.sh

Quick Start

$ hg clone https://www.mercurial-scm.org/repo/hello
$ cd hello
$ (edit files)
$ hg add (new files)
$ hg commit -m 'My changes'
$ hg push

Log

To see a certain revision, you can use the -r switch (–revision). To also see the diff of the displayed revisions, there’s the -p switch (–patch)

hg log -p -r 3
  • -r: –revision
  • -p: –patch

Amend

git commit --amend
hg rollback
hg commit -m 'this time is all right'

Git-SCM

Git

Configuration

git config --global user.name 'oxnz'
git config --global user.email yunxinyi@gmail.com
git config --global color.ui true
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.br branch
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
git config --global alias.type 'cat-file -t'
git config --global alias.dump 'cat-file -p'
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
# cache credential
# Set git to use the credential memory cache
git config --global credential.helper cache
# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'

~/.gitconfig

[push]
    default = matching
[user]
    name = oxnz
    email = yunxinyi@gmail.com
[color]
    ui = true
[alias]
    co = checkout
    st = status
    ci = commit
    br = branch
    hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
    type = cat-file -t
    dump = cat-file -p
    unstage = reset HEAD --
    last = log -1 HEAD

References