git

#dgplug training day 6

Image Posted on Updated on

We are into 6th day of the training and last day our instructor Kushal Das taught us how to use dig (a distributed version control system).

The start of the session seemed a little alien to me as I was clueless about it. Though after the sessions I did some poking around the internet, found a decent pdf to read on the same, actually the Git-documentation. Also found a history why Dig was created in the first place, I will probably write one post on the same. I also have an interesting documentary on the evolution of Open Source. Open source is all over all head 😛 . Anyways coming back to the session.

There were two sessions on Git, I am going to share few of the commands taught in the first session (the second session was post dinner and I am yet to work on that )

Git-Logo-2Color

In the first session we were introduced to some basic commands of Git.

to configure git, set your user name and e-mail address. This is important because every Git commit uses this information. The commands are:

$ git config –global user.name “Anurag Kumar”

$ git config –global user.email “anurag@example.com”

The names and the email address are to be changed as per the user.
Now that our identity is set,we were next asked to configure the default text editor that will be used by Git.  Git uses the default editor, which is generally Vi or Vim. I was using geddit as a default so needed to add vim (you need to have vim installed in your system). The commands are:

$ git config –global core.editor vim

now to check the settings, you can use the command:

$ git config –list

This will show you a list all the settings Git can find at that point.

Now, since we are starting on a fresh note, we will make an existing dir and then import in to git:

$ git init

This creates a new subdirectory named .git (inside a dir called repo01) that contains all of your necessary repository files.
Next were asked to create a empty file (naming that as progress.txt) inside the same directory and then commit in to git.

$ git log

will show the commit details that were made earlier. Next we were asked to add another line in the same file and see the changes and difference

$ git status

This will tell us that some changes were made to progress.txt but they are yet to be committed.

$ git diff

This will then show us the difference of the added text.Next comes the commit part:

$ git add progress.txt

$ git commit -m “Adds a new line to the file”

$ git log

A commit message will inform about the commit made. Next some more changes were made in the file and the commit was done again. Few interesting doubts were raised which came in handy understanding the whole process. Usually I try to observe what others are asking and most of my doubts are cleared .

If by chance one is stuck wondering in Git, help feature will point right direction to them for:
$ git help <verb>
$ man git-<verb>

For example:
$ git help commit

I am yet to explore more of git and next sessions will be interesting. The documentation might help anyone who needs to look out for information.

Until next.

Advertisements