Skip to main content

Git: Some Basics

Git is a Distributed Version Control  System that records changes to a file over time so that you can recall specific versions later. The main advantage of Git  over other VCSs is that we can do most of the operations in Git offline and hence Git is a much faster VCS. Using Git, our files can reside in any one of the three states: committed, modified and staged.

Committed means that data is safely stored in the local database

Modified means that we have changed the file but have
not committed it to the database yet.

Staged means that we have marked a modified file in its current version to go into the next commit snapshot.


Installing Git and Configuring the settings:

To install Git in Linux, we have to run the following command:

   $ apt-get install git-core 

To install Git on various other operating systems, please refer to more details

After installing, the next step is to configure the settings where you have to provide your identity such as name and email address. Following commands are used for this purpose

   $ git config --global user.name"Your name here"  
   # Sets the default name for git to you commit 

   $ git config --global user.email "Your email@youremail.com"
   # Sets the default email for git to use when you commit

Note that your email address for Git should be the same one associated with your GitHub account.

How to use a git repository:

Now we have installed Git and configured the settings. We can now start using Git to store and share our codes.We can get a git repository in two ways, first is to import an existing directory and the second method clones an existing git repository from an another server.
To initialize a repository in an existing directory, goto to the projects directory and type the following commands.

   $ git init
   $ git add <filename>
   $ git commit m ’initial project version’
To clone a repository, use the following command,

   $ git clone [url] 

After we have committed all the changes, we have to push the files to a remote repository. Use the commands:

   $ git push [remote-name] [branch-name]
   $ git push origin master
To check the status of our working directory and to know which files are in which states, use

   $ git status

After we have created several committs and if we want to look back what has happened over the time, use

   $ git log


These are some basic ideas regarding Git. Please refer GIT for the complete details.

Comments

Popular posts from this blog

Backbone.js - An Introduction

Backbone.js is a lightweight JavaScript library that adds structure to your client-side code.  Developers commonly use libraries like Backbone.js to create single-page applications (SPAs).  What is a Single-Page-Application? A single page Web App is a website that attempts to recreate the experience of a native desktop or mobile application. On a Single Page Web App you are less likely to see page refreshes, the browser navigation within the app is often overridden and  there will usually be some offline capabilities. To a user their interaction with a Single Page Web App will be almost identical to how they interact with a full native application. Backbone has many advantages over other js frameworks. Backbone is mature, popular, and has a number  of plugins and extensions available that build upon it. It has been used to create non-trivial applications by companies such as Disqus, Walmart, SoundCloud and LinkedIn. Backbone organizes its whole code under t...

Elements of Programming in Scheme

A powerful programming language provides a framework to interpret our ideas of processes. It generally combines small procedures to complex ones. Usually there are three steps to accomplish this. primitive expressions , which represent the simplest entities the language is concerned with, means of combination , by which compound elements are built from simpler ones, and means of abstraction , by which compound elements can be named and manipulated as units. Some very basic ideas in manipulating with the data are given below. Expressions   A very simple expression is a number. Simple expressions are combined to form complex ones. For example:                   (+ 2  3  4) is an expression where + is the operation and 2,3,4 are the oparents. The expression can be made more complex by combining simple expressions as given below:              ...

Abstraction Using Higher Order Procedures

Procedures are, in effect, abstractions that describe compound operations on numbers independent of the particular numbers. Yet even in numerical processing we will be severely limited in our ability to create abstractions if we are restricted to procedures whose parameters must be numbers. Often the same programming pattern will be used with a number of different procedures. To express such patterns as concepts, we will need to construct procedures that can accept procedures as arguments or return procedures as values. Procedures as arguments Procedures are often used as the arguments of an another procedure. This provides a higher level of abstraction in programming. For example consider a procedure to find out the sum of squares of numbers between a range. The procedures inc and square are used as the arguments of the procedure sum, which is generalised as follows.                 (define (inc...