tortoisegit 101 -- with github and tfstrinug.pbworks.com/w/file/fetch/67900854/tortoisegit.pdf · 4...

36
1 Author: Ian Zhang Date: 2013 TortoiseGit 101 -- with GitHub and TFS

Upload: duongdan

Post on 06-Feb-2018

229 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

1

Author: Ian Zhang

Date: 2013

TortoiseGit 101

-- with GitHub and TFS

Page 2: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

2

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.

Page 3: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

3

Installation

Page 4: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

4

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/

Page 5: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

5

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.

Page 6: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

6

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.

Page 7: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

7

Step 2: Install Tortoisegit

• http://code.google.com/p/tortoisegit/wiki/Download

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

Page 8: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

8

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.

Page 9: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

9

Connect GitHub with TortoiseGit

Page 10: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

10

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

• Go to github.com and create a github account if you don’t have one.

• Click “Create a Repository” link

Page 11: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

11

Create remote GitHub Repository (continue)

• Name the repository and click “Create repository” button.

Page 12: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

12

Create remote GitHub Repository (continue)

• Name the repository and click “Create repository” button.

Page 13: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

13

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.

Page 14: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

14

Clone remote repository to your machine

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

• Step 2: Click myrepo’s context menu and select “Git Clone”.

Page 15: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

15

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

Page 16: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

16

Add new project

Page 17: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

17

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

Page 18: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

18

Add new project to repository

• Project -> context menu-> TortoiseGit -> Add

Page 19: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

19

Add new project to repository

• Select files to add.

Page 20: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

20

Add new project to repository

• Hit Commit button

Page 21: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

21

Add new project to repository

• Add comments and hit OK button.

Page 22: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

22

Push to GitHub Server

• Project -> Context Menu -> Git Sync

Page 23: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

23

Push to GitHub Server

• Hit Push Button

Page 24: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

24

Push to GitHub Server

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

Page 25: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

25

Basic use of TortoiseGit

Page 26: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

26

Git Development Workflow:

Clone remote

repository

Pull recent code

from remote Edit code/Build

Add to staging area

Commit to local

repository

Pull to sync remote Local build

successful

Push to remote

repository

Page 27: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

27

Developer’s 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.

Page 28: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

28

Pull from GitHub

• The purpose of “Pull” operation is to get other people’s check in.

• Git “Pull” operation is the combination of Git “Fetch” operation and “Merge”

operation.

• Project -> context menu -> Git Sync -> Pull

Page 29: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

29

Change and Commit files.

• In Git, you don’t 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.

Page 30: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

30

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.

Page 31: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

31

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.

Page 32: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

32

Use TortoiseGit with TFS-GIT

Page 33: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

33

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

Page 34: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

34

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.

Page 35: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

35

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.

Page 36: TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4 Installation • To use TortoiseGit, you need to install following: o msysgit (GIT

36

My Blackberry 10 project on TFS

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