Home Articles Version Control With Git

Version Control with Git

PDF Print E-mail

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> pwd
/home/bob/workspace

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
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=gitadm@mygitserver:/opt/git/project.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

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.
gitadm@mygitserver's password:
Permission denied, please try again.
gitadm@mygitserver's password:
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
total 4
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
LearningMake
LearningMake/util.c
LearningMake/main.c
LearningMake/Makefile

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)
To gitadm@mygitserver:/opt/git/project.git
   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

Join us at the Agile Development Conference for IT Governance and Compliance in an Agile World Date: Wednesday November 07, 2012 2:15pm Presenter: Bob Aiello, CM Best Practices Consulting Description: Establishing IT governance and compliance practices is essential for organizations that have regulatory or audit requirements. The good news is that you can be agile and still comply with Sarbanes-Oxley, CFR 21, HIPAA, and other regulatory imperatives. Done well, IT controls actually help you improve both productivity and quality. Bob Aiello describes how to implement IT controls in frameworks such as ISACA, Cobit, and ITIL v3 that many regulatory frameworks require—while maintaining agile practices. Bob’s guidance includes specific examples of establishing IT controls: separation of duties, work-item to change-set traceability, physical and functional configuration audits, and more. Bob explains how these practices help government, defense-related, and other critical mission corporations scale agile practices where audit and regulatory compliance is a must. In fact, Bob attests to the fact that a disciplined approach to agile can improve the productivity and quality of most all agile development efforts. Also, please join us the day before for Configuration Management Best Practices training    
Join us at the Better Software Conference for Configuration Management Best Practices training Date: Monday, June 2nd, 2013 8:30 AM Presented by  Bob Aiello, CM Best Practices Consulting Description Robust configuration management (CM) practices are essential for creating continuous builds to support agile’s integration and testing demands, and for rapidly packaging, releasing, and deploying applications into production use. Classic CM—consisting of identifying system components, controlling changes, reporting the system’s configuration, and auditing—won’t do the trick anymore. Bob Aiello presents an in-depth tour of a more robust and powerful approach to CM consisting of six key functions: source code management, build engineering, environment management, change management and control, release management, and deployment. Bob describes current and emerging CM trends—support for agile development, cloud computing, and mobile apps development—and reviews the industry standards and frameworks that are essential in CM today. Take back an integrated approach to establish proper IT governance and compliance using the latest CM practices while offering development teams the most effective CM practices available today.      
 
Copyright © 2017 CM Best Practices. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.
 

Product News

Live Online Training

Jobs