DevOps Activity - Save time during Git clone and application builds

 The size of a Git repository increases with time. It may grow to few GB size, like 2 GB or 5GB or even more.


Cloning a 2 GB Git repository may take about 10 minutes, which slows down productivity of the developers.


There are three ways to save time during cloning a Git repository.


1. Cloning single Git branch:

You can clone one one branch you want. This will ignore other branches and will save cloning time.

git --single-repo -b <name of branch>


2. Ignoring commit history:

During normal cloning, git will clone all commit history. If you don't need all the history at once, you can just clone the last one commit history only. This will save significant time and disk space during cloning.

git --depth 1


3. Referencing your local cloned git repository:

If you have already cloned your repository on your laptop or desktop, then you can use the --reference option in git command. This option will point to your local git repository and will reference the remote git repository only if newer modification have been made This will save time as unmodified code will be copied locally and only modified ones from the remote git repository.

git --reference (mention your previous locally cloned git repository)

Complete command:

time git clone --single-branch -b master --depth 1 --reference ~/student01/local-kubernetes-code https://github.com/k8s/project-marine k8s-marine-ref

NOTE: You can use Linux time command at the start of your git commands to measure time taken to clone. For example, you can compare time it took without the three ways and then find the time you will save after using them.


Hope this helps in your daily DevOps activities to increase productivity. Let me know if there is any comment or suggestions.



Comments

Popular posts from this blog

Install Puppet Client on RHEL 6.4

Install IBM Tivoli TSM 5.5 Backup Server (trial) on your Laptop using Linux KVM virtual machine

IBM TSM Client 5.x install (trial) on your Laptop using KVM Virtual Machines