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