Git is a very popular distributed version control system that some very cool features and also a few limitations. I like git and view it as a good choice for some organizations. This is the first of a series of articles on how to get up to speed with using git.
Note that I recently reviewed Accurev's awesome new Kando product which provides a bridge between Git and industry strength Accurev.
Let's start by creating your first repository. (In a future article we will explain some of administrative tasks necessary to support git.)
cmbp> git init
Initialized empty Git repository in /home/bob/workspace/.git/
cmbp> git remote add origin gitadm@mygitserver:/opt/git/project.git
cmbp> git config --list
The lines above show the initialization of a new git repository. Next we add the location of the remote repository that we want to be able to clone. The step that clones the repository is shown next.
cmbp> git clone gitadm@mygitserver:/opt/git/project.git
Initialized empty Git repository in /home/ysiadmin/workspace/project/.git/
The authenticity of host 'mygitserver (mygitserver)' can't be established.
RSA key fingerprint is ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff.ff.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'mygitserver' (RSA) to the list of known hosts.
Permission denied, please try again.
remote: Counting objects: 5403, done.
remote: Compressing objects: 100% (4242/4242), done.
remote: Total 5403 (delta 1061), reused 5362 (delta 1054)
Receiving objects: 100% (5403/5403), 21.67 MiB | 25893 KiB/s, done.
Resolving deltas: 100% (1061/1061), done.
The lines above show the local git repo receiving objects from the master that has been cloned. This is an important aspect of the git usage model. This results in the git project repo shown below.
cmbp> ls -lt
drwxr-xr-x 6 ysiadmin ysiadmin 4096 Feb 19 18:30 project
Next we will add a directory called LearningMake, Makefile and a couple of C programs.
cmbp> find LearningMake
The files above are only in the local directory and we need to add them to the local git repo, commit and then push them to the Master git repo.
cmbp> git add LearningMake
cmbp> git commit -am "Adding LearningMake dir and files"
Created commit 02fc8b8: Adding LearningMake dir and files
3 files changed, 37 insertions(+), 0 deletions(-)
create mode 100644 LearningMake/Makefile
create mode 100644 LearningMake/main.c
create mode 100644 LearningMake/util.c
cmbp> git push origin master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 429 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
d8e2921..02fc8b8 master -> master
There are a number of good reasons to push your changes to the master repo. The reason is that we assume that the master repo is being backed up but your local repo, possibly on your laptop, might not be. This is not an uncommon usage with distributed version control tools. You can also use the master repo to share changes between users who otherwise can work in isolation.
Git has some limitations though. For one thing there are circumstances under which the history log can be modified with an audit trail. This could create an audit issue and I am interesting in discussing this issue with other technology professionals who are using Git in environments that must meet regulatory requirements. The other issue is that git relies upon shared keys and does not, at this time, support LDAP, active directory or other common user authentication mechanisms.
I recently reviewed Accurev's Kando product which addresses these issues and still allows your developers utilize git as a light weight feature rich version control system. It is worth noting that git makes use of cryptography (e.g. MAC SHA1 hashes) to ensure repository integrity. This important feature puts it way ahead of other open source version control systems and even a few commercials ones too.
Please drop me a line and tell me about your experiences using git and what you would like to learn next. My vote is branching and baselining with git!
More articles by this author