Вы находитесь на странице: 1из 36

TortoiseGit 101

-- with GitHub and TFS

Author: Ian Zhang

Date: 2013


Git is developed by Linus Torvald around 2005 for Linux.

Git has strong Unix culture. Most of the power GIT commands are
executed in command line.
Some GUI developers are not familiar with command line commands.
TortoiseGit provides a GUI client for Git server. It is integrated with
Windows File Explorer.
GitHub is a hosted Git server and very popular among open source
This document is to provide a basic tutorial to use TortoiseGit with



To use TortoiseGit, you need to install following:

o msysgit (GIT for Windows)
o TortoiseGit

You may find detail information from following page:


Step 1: Install msysgit


Pick the latest version.

Step 1: Install msysgit

Follow most of default selections.

In configuring the line ending conversions (picture 5), I change it to
Checkout as-is, commit Unix-style line ends since I am more generic.

Step 2: Install Tortoisegit

Pick 32 bit or 64 bit version according to your OS.

Step 2: Install Tortoisegit

Follow all default selections.

In configuring the line ending conversions (picture 5), I change it to
Checkout as-is, commit Unix-style line ends since it is more generic.

Connect GitHub with TortoiseGit

Create remote GitHub Repository:
(skip this step if you use existing GitHub repository)

Go to github.com and create a github account if you dont have one.

Click Create a Repository link

Create remote GitHub Repository

Name the repository and click Create repository button.

Create remote GitHub Repository

Name the repository and click Create repository button.

Clone remote repository to your machine

The purpose of this step is to clone the repository from remote server
to your local machine.

The concept is quite different from traditional centralized version

control system.
All the codes will be downloaded to your local machine.
All branches and tags will be downloaded to your local machine.
All history will be downloaded to your local machine.

Download all your company last 10 years codes to your local

machine? That is Git.

Clone remote repository to your machine

Step 1: Create a normal folder (myrepo) on your local machine.

Step 2: Click myrepos context menu and select Git Clone.

Clone remote repository to your machine

Step 3: From GitHub page, copy repository root URL.

Step 4: Paste the repository root URL to the TortoiseGit popup on
your local machine. Uncheck Load Putty Key and click OK

Add new project

Start New Project:
You have created a folder myrepo on your local machine.
You have created a project repository on github (TriNutProj).

Add your code files in your folder myrepo / TriNutProj.

Create a .gitignore file for your project (optional). The purpose of .gitignore
file is to ignore certain type of files (e.g. obj file and exe file).

Add new project to repository

Project -> context menu-> TortoiseGit -> Add

Add new project to repository

Select files to add.

Add new project to repository

Hit Commit button

Add new project to repository

Add comments and hit OK button.

Push to GitHub Server

Project -> Context Menu -> Git Sync

Push to GitHub Server

Hit Push Button

Push to GitHub Server

After you provide github username and password. You should have success.

Basic use of TortoiseGit

Git Development Workflow:

Clone remote Pull recent code

Edit code/Build
repository from remote

Add to staging area

Commit to local

Push to remote Local build

Pull to sync remote
repository successful

Developers daily life
1. Pull remote repository (optional)
2. Edit the file / Add new files.
3. Local build
4. Add the changed files to staging area
5. Commit files to local repository to create a local milestone.
6. Repeat step 2 to step 5 if needed.
7. Push the change to central repository
1) Pull the remote repository.
2) Merge the conflict
3) Local build and fix the error
4) Push to remote repository.

Pull from GitHub

The purpose of Pull operation is to get other peoples check in.

Git Pull operation is the combination of Git Fetch operation and Merge
Project -> context menu -> Git Sync -> Pull

Change and Commit files.

In Git, you dont need to check out file to change the content.
You can use any editor to change files.
When you commit the change. You need Add new file to the git, then commit.
After commit, it is only in your local repository. It is a local milestone.

Push the change to github server.

In order for other people to see the change, you need to push the change(s) to
github server.

Next steps:

Git is a very power full tool. This tutorial only cover basic operation. In order to
use Git correctly and efficiently, you need to consult with your configuration
manager and system architect for following:

Repository strategy
Branch and release strategy
How to connect Git to code review tool and automatically build.
How to revert a change.

Use TortoiseGit with TFS-GIT

Just like Apple fans, Microsoft developers love TFS.
TFS is very popular in Microsoft development paradigm. But it is very
unpopular outside.
TFS is tied with Visual Studio. Add Java, Perl script and other files to Visual
Outside world > Microsoft world. Big companies normally do not depend on
one vendor.

Therefore, it comes with TFS-GIT.

You can use TFS-GIT within the Visual Studio for Microsoft project.
You can use normal Git client to connect TFS-Git.

We will describe how to connect TortoiseGit to TFS-Git. You can use this
strategy to cover both Microsoft development and non-Microsoft development
(e.g. Java, Perl, etc.).

Create TFS-Git Project

Go to http://tfs.visualstudio.com/en-us/tfs-welcome.aspx
Create a free account.
In your page, create a new team project using TFS-Git template.

Enable TFS-Git for TortoiseGit

In order to use TortoiseGit with TFS-Git, you need to enable "Alternative

Authentication Credentials" in TFS server.
1. Click Your name on the right.
2. Go to My Profile
3. Click on the Credentials tab
4. Set up an alternate username doesn't include the @ character
5. Now when you connect to the remote repo via TortoiseGit in normal way.

My Blackberry 10 project on TFS

This is my bb10 project on TFS. No Visual Studio is needed.