Dariusz on Software

Methods and Tools

About This Site

Software development stuff


Git Version Control System usage techniques
Sat, 04 Oct 2008 07:15:49 +0000
We (Aplikacja.info) are a small Polish software company that write mostly in Python language and use Linux for development. GIT is an advanced version control system that was created by Linux Torvalds for maintain Linux kernel source tree. I'll show how git can be connected in Unix shell environment with make tool. Why GIT have been chosen to support our version control needs?
  • Failure in development server will not block our work
  • Access to history is very fast (it's stored on every working copy)
  • I used to work during flight, GIT supports all VCS operations off-line (commit, diff, etc.)
The hard thing about GIT is that it may confuse beginners. If you are one, remember:
  • Always use git diff HEAD instead of git diff
  • Always using git commit -a instead of git commit
Some of this gotchas have been addressed by some GIT interfaces, but they are deprecated now. In order to ease GIT (and earlier, CVS) usage we introduced additional Makefile targets that handle typical source control tasks.

Examining working copy.

make st shows current working copy state with all local branches and current selected branch:
        git branch
        git status -a | cat
(cat simply remove pager call). make di shows differences between last committed version and working copy:
        git diff HEAD
Locally stored history (few last commits) can be inspected by make ch:
        git log --pretty=oneline -15 | cat
We are using topic branches strategy to develop software, so switching branch (make sb) is a very common operation:
        @read -p "name of existing branch to switch to [a-z_0-9]+: "\
        git checkout $$branch_name;

Local commits

If we have some changes uncommitted in working copy we can commit them now:
    commit: di st
        git commit -a
Above command shows current changes to be committed (di) and state of a repository (st) then allows to enter comment.

Going remote

Lets synchronise our working copy with central repo (without locally unmodified changes): make sync:
        -git pull $(REPO) +`git branch | awk '/^\*/ {print $$2}'`
        git push $(REPO) `git branch | awk '/^\*/ {print $$2}'`
It downloads current branch from central server (this operation can fail when no branch exists yet, so we ignore errors here by "-" character) and pushes un-synced commits made.
Tags: git.


Created by Chronicle v3.5