Here, we will learn how to use git, the widely-used version control system initially developed by Linus Torvalds for Linux kernel development.
First, obtain the software git by
$ sudo apt-get install git -y
Next, clone git repository from GitHub by
$ git clone https://github.com/git/git
When download is complete, it will have create a folder, so let's enter.
$ cd git
Well, we could simply build the current version of git, but for the sake of learning how to use git and getting the taste of what it is capable of doing, let's check out the very first version of git written by Linus in 2 weeks.
To do this, we first need to search for different commits:
$ git log --oneline
Now, scroll the to the very bottom by pressing 'end' key several times.When you reach the end, press 'q' key. You should see the following output:
e83c516 Initial revision of "git", the information manager from hell
This is the very first version (present in the repository). Let's check out this version by
$ git checkout e83c516
Now, you will see that the files in the folder have been de-dated back to 2005! How do I know? Well, run
$ git log
Because we will make changes and commit this soon, we will create a branch here, so simply run
$ git checkout -b ver1.0
Let's take a look at what branches we have now
$ git branch
Note that ver1.0 branch has been added, where master is the current version of git.
There are only a handful of files here at this very early stage. Feel free to read Linus' code. When done, let's compile. First, you will need to install libraries:
$ sudo apt-get install libssl-dev zlib1g-dev -y
When you run
$ make
It will probably complain about some define references. We will need to edit the Makefile file and include some libraries:
$ vim Makefile
Add -lz and -lcrypto parameters for LIBS flag, so line #11 should read
LIBS= -lssl -lz -lcrypto
Save the file and let's try to compile again
$ make
This should compile! Now, let's commit the change to the local repository:
$ git add Makefile
$ git commit -m "edit Makefile to compile in Ubuntu 14.04LTS"
To go back to the current version of git, we check out the master branch$ git checkout master
To go back to the compilable first version of git, simply run
$ git checkout ver1.0
I will go through some more advanced git tutorials later.
No comments:
Post a Comment