Skip to main content

Quick notes on Git

 

I have been away from writing anything for a long time and instead have been fooling around with other stuffs like just plain reading, growing mustache, trying to learn swimming, trying to learn to play acoustic guitar and trying my hands at photography. To be honest I have not given up on them yet but neither have I been able to hang on to them in a disciplined manner. So here I am back to my writing after a long gap.
This time its going to be quick notes on Git.
  1. Git is a file repository.

  2. As opposed to other repositories like SVN Git thinks of its data more like a snapshot of a mini filesystem.

  3. All operations in Git are local. (Entire history of the project is stored locally in your working directory)

    • Browsing project history.
    • Viewing all changes to a file.
  4. Git uses Checksum to track repository items

    • Everything in Git is check-summed
    • It uses SHA-1 hash for generating check sum values
  5. All actions in Git only add data to Git database.

  6. There are three main states in Git

    • Committed – means that data is safely stored in your local database
    • Modified – means you have modified the files but have not yet committed to your local database.
    • Staged – means that you have marked a modified file in its current version to go into your next commit snapshot.
  7. Correspondingly there are three main sections of a Git Project –

    • Git directory (repository) – is where Git stores the metadata and object database for the project. This is what is copied when you clone a repository from another computer.
    • Staging Area - is a simple file, generally contained in your Git directory, which stores information about what will go into your next commit. Also referred to as the index.
    • Working Directory – is a single checkout of one version of the project.
  8. There are two types of files

    • Tracked – files that were part of the last snapshot
    • UnTracked – any files in your working directory that was not in your last snapshot and is not in your staging area.
  9. Basic Git Workflow –

    • You modify your files
    • You stage the files
    • You do a commit.
  10. Getting ready with Git –

    • Go to https://github.com/signup/free and setup your account.
    • Download and Installing Git - http://git-scm.com/download/win
    • Setup your Identity
      1. After installing goto Start -> All Programs -> Git -> Git Bash
      2. At $ prompt type git config --global user.name “Your Name” and enter
      3. At $ prompt type git config --global user.email “Your email address” and enter
      4. To verify that this has been saved at $ prompt type git config --list and enter
      5. You can also go to c:\documents and settings\username\ (or C:\Users\username) now open the .gitconfig file in any editor to see the user.name and user.email details you just provided above.
    • Now go to the site login and create your First repository
    • Back to your Git Bash to clone your repository to work locally at $ prompt type the following: git clone “your repository url” “d:\gitwork\projectfolder”
    • Changing over to the working folder at $ prompt type the following: cd d:/ GitWork/projectfolder
    • Checking the status at $ prompt type git status
    • Create a sample text file with some dummy content – HelloWorld.txt at D:/GitWork/projectfolder folder
    • Now at the $ prompty type git add HelloWorld.txt and then git status which should show our HelloWorld.txt as untracked file.
    • To commit the changes just say git commit and enter the comments when requested.
    • Next to synch up your online repository with local database you type following: git push -u origin master
    • Now if you check the online repository contents in your account you should be able to see your files and changes.
  11. Working with Git Bash -

    • At $ sign command prompt type echo ‘whatever text you want to type here’ which will cause the editor to spew out that text back on your command prompt.
    • You can also setup an editor of your choice by typing at $ prompt git config --global core.editor <editorname>
    • You can also setup a diff tool using $ prompt git config --global merge.tool <toolname>
  12. There is an excellent book online here - http://git-scm.com/book

Comments

deepak aggarwal said…
Welcome back Abhy.. :)
Nice post on something quite popular. Will try Git based on your steps. Just adding one more input (read somewhere). There is an extension for integrating Visual Studio with Git here.
Abhy Nadar said…
Thanks Deepak. I will sure explore the VS extension.

Popular posts from this blog

Notes on Castle MonoRail

  Sometime back I was doing a small POC on Castle MonoRail. So here are my quick notes on this. MonoRail is an MVC Framework from Castle inspired by ActionPack. MonoRail enforces separation of concerns with Controller handling application flow, models representing data and View taking care of the presentation logic. To work with MonoRail you need Castle Assemblies. It also utilizes nHibernate You can use Castle MonoRail Project Wizard or create the project manually. Project structure – Content Css Images Controllers HomeController.cs Models Views Home \ index.vm Layouts \ Default.vm ...

Workflow Foundation 4 - Part 3 - Data storage and management

This is my third post on WF4. First one was an introductory post on WF4 and in second one we focused on executing workflows. In the this post I am going to focus on the topic of data storage and management. Every business process or flow depends on data. When you think of data there are three elements to it as listed below - Variables - for storing data Arguments - for passing data Expressions - for manipulating data. Let us first look at the variables. Variables are storage locations for data. Variables are declared before using them just like in any other languages like C# or VB.Net. Variables are defined with a specific scope. When you create a variable in an activity the scope of the variable becomes that activity's scope. Variables can also have access modifiers like None, Mapped or ReadOnly. Let us look at an example where we will create two variables and assign a scope to them along with access modifiers. //Declare a sequence activitiy Sequence seqWf = new Sequence(); //de...

Introduction to Workflow Foundation 4 (WF4)

I finally decided to pick-up my blogging once more. Since I have been trying to learn Windows Workflow Foundation 4 (WF4) I thought I might as well start off with this topic. WF4 is a development framework that enables you to create a workflow and embed it in a .Net application. It is neither an executable application nor a language. It provides a set of tools for declaring a workflow, activities to create your logic and to define control flow and a runtime for executing the resulting application definition. It also provides services for persistence of state, tracking and bookmarking. You can create your workflow directly in code, in mark-up or in a combination of both. Workflow provide us with two major advantages - Creating unified application logic. Making application logic scalable. Workflow Authoring styles - Sequential Workflow executes a set of contained activities in a sequential manner. Workflow Foundation was introduced in the .Net 3.0 and updated in 3.5. In .net 4 it has bee...