Sie sind auf Seite 1von 36

TortoiseGit 101

-- with GitHub and TFS

Author: Ian Zhang


Date: 2013

1
Background

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
community.
This document is to provide a basic tutorial to use TortoiseGit with
GitHub.

2
Installation

3
Installation

To use TortoiseGit, you need to install following:


o msysgit (GIT for Windows)
o TortoiseGit

You may find detail information from following page:


http://code.google.com/p/tortoisegit/

4
Step 1: Install msysgit

http://code.google.com/p/msysgit/downloads/list?can=2&q=Full+install
er+for+official+Git+for+Windows

Pick the latest version.

5
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.

6
Step 2: Install Tortoisegit

http://code.google.com/p/tortoisegit/wiki/Download
Pick 32 bit or 64 bit version according to your OS.

7
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.

8
Connect GitHub with TortoiseGit

9
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

10
Create remote GitHub Repository
(continue)

Name the repository and click Create repository button.

11
Create remote GitHub Repository
(continue)

Name the repository and click Create repository button.

12
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.

13
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.

14
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

15
Add new project

16
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).

17
Add new project to repository

Project -> context menu-> TortoiseGit -> Add

18
Add new project to repository

Select files to add.

19
Add new project to repository

Hit Commit button

20
Add new project to repository

Add comments and hit OK button.

21
Push to GitHub Server

Project -> Context Menu -> Git Sync

22
Push to GitHub Server

Hit Push Button

23
Push to GitHub Server

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

24
Basic use of TortoiseGit

25
Git Development Workflow:

Clone remote Pull recent code


Edit code/Build
repository from remote

Add to staging area

Commit to local
repository

Push to remote Local build


Pull to sync remote
repository successful

26
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.

27
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
operation.
Project -> context menu -> Git Sync -> Pull

28
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.

29
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.

30
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.

31
Use TortoiseGit with TFS-GIT

32
Why 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
Studio?
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.).

33
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.

34
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.

35
My Blackberry 10 project on TFS

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

36

Das könnte Ihnen auch gefallen