I use Git with Visual Studio. But I don’t use the GUI,I just keep a command line open as well as Visual Studio. (We are developers and we love typing code )
But here a nice GUI tool that integrates git with Visual Studio
Introduction
This post talk about how to make a simple environment to personal source control with Git Bash, Git GUI and Visual Studio 2010
Some Basic Git Concepts
What is Git:
Git is a distributed version control system that records changes of you software projects.
Repositories
A Git repository is simply a database containing all the information needed to retain and manage the revisions and history of a project. **
Commits
In Git, a commit is used to record changes to a repository. **
Branches
The best way to understand what is a branch is doing commits, when you commit in Git, Git stores its data as a series of snapshots. “Every time you commit, in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.” ** If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. A branch in Git is simply a lightweight movable pointer to one of these commits. A branch often represents an individual customer release. The default branch in a repository is named master
Installing Git (msysGit)
First, download the latest version from: http://code.google.com/p/msysgit/downloads/list After the download completes, run the installer
For easier msysGit run, check the two pertinent boxes, to add in the Windows Explorer, as shown
Let’s get started
Git is simple to use. Go to All Programs and open Git Bash
Or just open a Command Prompt and type Git.
Configuring the Commit Author
Before making many commits to a repository, you should establish some basic configuration options.
- Start Git Bash
- git config –global user.name “Your Name”
- git config –global user.email “your@mail.com”
Create a new Visual Studio Solution with a project (for this example a Silverlight application)
Write Code and Save Changes or run the application (F5)
< Rectangle Width="300" Height="100" Fill="Red" />
Creating an Initial Repository
Go to solution folder and select “Git Bash here” or at the Command Prompt type “cd path\to\your\solution\folder “
To initialized empty Git Repository in your path
At Command Prompt Type:
- git init
- git add .
- git commit –m “first commit ( with a rectangle )
Now to get a UI tool Type: gitk We have a first version of our application
Now let’s make some modifications
We can add more files (class, service etc.) and commit this changes
< Ellipse Width="300" Height="200" Fill="Purple" />
Save changes in Visual Studio and add the change to Git
Making another Commit
At Command Prompt Type:
- Git add .
- Git commit –m “Change to Ellipse And so on for other changes in your solution
Viewing the Commit History
Once you have one or more commits in the repository, you can inspect it
At Command Prompt Type:
• Gitk
Our History of changes:
What happen if we want back to first commit?
Simple in gitk select “Reset master branch to here”
Next Visual Studio will detect the changes and reload the solution
We Back to First Version
We can back to other version commit
The .gitignore File
You can skip any file by adding its name to .gitignore in the same directory.
For this example in visuals studio , Those are irrelevant files:
bin/ |obj/ |_ReSharper.* |*.csproj.user |*.resharper.user |*.resharper |*.suo |*.cache | *.user |~$*
As you have seen, git is awesome, faster, has ability to handle large projects, distributed, no heavy services or relational database to stored data.
There are lots to learn, but at the moment that’s all folks.
References: