- Learn Linux
- Learn Electronics
- Raspberry Pi
- LPI certification
- News & Reviews
20 January 2015
Git is a version control system. A way of keeping regular backups of files which is particularly useful for creating computer source code.
I've used other version control systems before (CVS and Subversion) and other tools that provide an element of version control (eg. Dropbox), but so far I've only really used them when I needed to for specific software projects. Elsewhere I've been manually creating backups as required, which includes the code and data files used in my websites. I first starting using git almost 2 years ago and continued to use it in the same way as I did before. I've since learned more about Git and my use of version control has now completely changed.
I had picked up the basics of git through some projects I've been working on and I started using it for my own projects, but just by having an account on github and pushing my open source project code there. I had read up on how to use git, but was just using it in a similar way to how I used the other version control systems before. I am now studying for an MSc in Computer Science with Georgia Tech and my current class on Software Development Process (CS 6300) includes git as one of the "tools of the trade".
As well as the course video I have watched a Udacity course. Note that Udacity also provide the platform for my degree course which is where I found this course.
Udacity course - How to Use Git and GitHub
GitHub is the main provider of git repositories and is free for open source projects. It does support private repositories, but there is a charge for this. The cost is reasonable and it provides the reassurance of a professional run server but I just wanted something that I could run on my own server. It is possible to install a full blown git server using GitLab, but for a basic repository it's possible to create a basic server just using ssh - which I already had installed.
I created a git user with login restricted to git shell (/usr/bin/git-shell) and copied my public key for my other computers to /home/git/.ssh/authorized_keys
I then created directories for each of the repositories and initialized them as git repositories using
git init --bare
and I could then push and pull to the repository.
Note that as I'd disabled login as git I switched to the git user using
sudo -su git
I've used this for maintaining the files used for my websites.
These are some of the customizations I have done.
git config --global user.name "User Name"
git config --global user.email email@example.com
git config --global core.editor "vim"
git config --global push.default upstream
git config --global merge.conflictstyle diff3
git config --global color.ui true
I added the entries
export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"
There is lots more information available on Git. Here are a few I've found useful.