TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4...
Transcript of TortoiseGit 101 -- with GitHub and TFStrinug.pbworks.com/w/file/fetch/67900854/TortoiseGit.pdf · 4...
![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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/1.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/2.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/3.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/4.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/7.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/10.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/11.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/12.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/13.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/14.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/16.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/17.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/18.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/19.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/20.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/21.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/22.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/23.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/24.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/25.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/26.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/27.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/28.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/29.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/30.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/31.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/32.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/33.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/34.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/35.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062413/5a78fbf97f8b9a68148d8a85/html5/thumbnails/36.jpg)
36
My Blackberry 10 project on TFS
This is my bb10 project on TFS. No Visual Studio is needed.