Sunday, March 23, 2014

Remote git useful commands

For the remote branch, I created a free github account and created a repository in there.

Clone remote repository

git clone

First push to gitserver

git push --set-upstream origin master

Subsequent pushes to gitserver

git push                                                 

Show local branches

git branch                         

Show remote branches

git branch -r

Show remote url

git remote -v

Get data from remote repository

git fetch

Merge the fetched data

git merge

Fetch and merge in one step

git pull

Tag a branch with v1.0 

git tag v1.0 

Tag a branch with v1.0 and add a message

git tag -a v1.0 

Create a signed tag

git tag -v v1.0

List all tags

git tag -l

Get the code with tag v1.0

git checkout tags/v1.0

Get the code with tag v1.0 and create a new branch named b1 with that code

git checkout tags/v1.0 -b b1
Push with tags

git push --tags

Introduction to Git for beginners (What is git?) (Git tutorial)

Introduction to Git

Git is a free distributed version control system. What distributed means here is that every single developer contains a source repository on their individual machine.

The diagram below shows the difference between a centralized version control system TFS (Team Foundation Server)  and git. Notice that in git, every developer installs git on his machine and has the complete repository locally.

Git was written in Perl and C. Git can be installed on Mac, Linux, Windows and Solaris.

The main advantages of git are
  • You have your repository, so you can work completely disconnected from the main repository until you are ready to check in. (Until then you check in to you local repository)
  • Works across multiple operating systems. This is a big plus for bigger companies who have development on multiple platforms.
  • Handles large projects fairly easily
  • Strong branching and merging support
However Git also has these drawbacks
  • Steep learning curve
  • No inbuilt GUI support
  • Since you get the entire history of the files into your repository, initial fetch might take longer.
  • No locking support

Git itself does not have a GUI and only supports interaction through the command line console. However there are many free/paid third party GUI clients for git.

 For small personal projects and for learning, you can use github as your central repository. If you are setting up git for your organization, and don't want to put your code on a server that you don't control, then you could set up your own git server instead of using github. Typically this is what large organizations do.

Installing Git

For Mac, use the homebrew command
brew install git                   

Download git from here. When installing, except for the one screen shown below, use all the default options. Selecting the option as shown in the screen shot will make the git.exe command available from any path in the command prompt console window.

After the installation is over append ;<Git Installation location>\bin (for me that is ;C:\Program Files (x86)\Git\bin ) to the environment variable "Path". This is to make the ssh.exe command available from any path in the command prompt console window.

To get to environment variable click Start. Then right click Computer>properties. In the new window that opens up, click "Advanced System Settings". In the window that opens up, click "Environment variables" button.

Now you are ready to start using git. Enjoy!

Further reading:

Useful Git Commands

Thursday, March 20, 2014

Useful Git Commands

Show git global (user level) configuration information

git config --global --list  

Create global (aka user level) settings

git config --global "Vivek Menon"                               

git config --global ""  

Set notepad++ as the default editor for git (works in windows 64 bit)

git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"  

Create a git repository

git init  

View Pending Changes

git status 

Add a new file (stage a new file) named play.txt to git

git add play.txt

Add all the untracked files into git in one command

git add * 

Stage all existing files that has been updated

git add -u

Commit changes to local repository

git commit -m "adding a new file"

Stage and commit in one single command

git commit -am "my comment"

Show history

git log 

(latest changes show up on the top)

(type q to exit)

Show difference between the last two commits

git diff Head~1 Head

(Head is the latest commit. Head~1 means one before the latest)

Delete a file hello.txt  

git rm hello.txt                          (stage for deletion)

git commit -m "delete hello.txt" (commit deletion)

Get back the deleted file hello.txt

do git log to see all the commits 

do git checkout <SHA-1 hash of the commit I need> hello.txt

Undo all changes that have not been staged or committed

git reset --hard

Sunday, March 9, 2014

What is cloud computing? (Introduction to cloud computing)

What is cloud?
Cloud computing is basically just a service. For example gmail is a cloud based service which comes under the category of Saas (software as a service).

Types of cloud
In a simplified view cloud can be broadly classified into the following three categories
Saas (Software as a service)
Paas (Platform as a service)
Iaas (Infrastructure as a service)

Saas is a service where you get a software to consume.
Consumers: The common man
Examples: Gmail, Google docs, Facebook, Microsoft Office 365

Platform as a service is one layer deeper than Saas. In Paas you get a ready made software development platform with SQL server, IIS web server and other softwares that you need to start writing applications.
Consumers: Developers
 ExamplesGoogle app engine, Microsoft Azure (Note Azure has both paas and iaas offerings).

Infrastructure as a service offers even more control than paas. In Iaas you use a self service portal where you fill in details such as how much RAM you need , how many CPUs you need, pick the iso image that you want to deploy on your VM and so on.
Consumers: Business within an organization, Developers, IT
Examples: Amazon Elastic Compute Cloud 

Remember here, to qualify as cloud it should be an automated service. If your IT department gives out virtual machines in your datacenter, that DOES NOT qualify as cloud. However if you can use a website to request VMs in your private datacenter, where the request can get completed in an automated manner, without any need for human intervention (except for approvals), then that could qualify as cloud.

Many people confuse between cloud and virtualization. Virtualization is NOT cloud. Virtualization is a component of the cloud.

Private and Public cloud
If you are using VMware cloud infrastructure to create a cloud service, where your data resides on your own servers, then that would qualify as private cloud.
If you use a third party service like Amazon EC2, where your data resides on somebody else's server, then that is a public cloud.