Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just...
Transcript of Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just...
![Page 1: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/1.jpg)
Introduction to gitA lecture arranged by Ludd and Arctic Group
Anders Engstrom
7 April 2016
1 / 27
![Page 2: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/2.jpg)
Overview
IntroductionIn a world without versioncontrolTypes of version controlThis is git
Getting startedPreparationsYour own repositoryFirst time with a repositoryConnect more users
Using git
Everyday useTagsBranchingUndoA closer look at the historyIgnoring filesGit on Windows
ConclusionSummaryBibliography and linksQuestions and comments
2 / 27
![Page 3: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/3.jpg)
Overview
IntroductionIn a world without versioncontrolTypes of version controlThis is git
Getting startedPreparationsYour own repositoryFirst time with a repositoryConnect more users
Using git
Everyday useTagsBranchingUndoA closer look at the historyIgnoring filesGit on Windows
ConclusionSummaryBibliography and linksQuestions and comments
3 / 27
![Page 4: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/4.jpg)
In a world without version control
How do you work in a group?
I Shared folder.
I Mail files back and fourth. (All files or only changed ones?)
I Instant messaging.
How do you undo changes?
I Rewrite parts of the code so that it looks the same as before.
I Create a copy in advance according to a naming convention.
I Search through old mails.
Can you come up with any more ways?
4 / 27
![Page 5: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/5.jpg)
Types of version control
How do you handle multiple users?
I File locks
I Merge
Where is the information stored?
I Centralized
I Distributed
5 / 27
![Page 6: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/6.jpg)
This is git
Git is:
I A fast distributed version control system.
I Written for the Linux kernel (by Linus Torvalds et al.)
I Lots of other projects also use it.
I Git is open source, GPL etc.
We will look at:
I Mostly the official command-line client. (Also available forWindows.)
I A little bit of a graphical client. (The concepts are the same.)
6 / 27
![Page 7: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/7.jpg)
Overview
IntroductionIn a world without versioncontrolTypes of version controlThis is git
Getting startedPreparationsYour own repositoryFirst time with a repositoryConnect more users
Using git
Everyday useTagsBranchingUndoA closer look at the historyIgnoring filesGit on Windows
ConclusionSummaryBibliography and linksQuestions and comments
7 / 27
![Page 8: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/8.jpg)
Preparations
Who are you?
1 g i t c o n f i g −−g l o b a l u s e r . name ”Anders Engs t r om”2 g i t c o n f i g −−g l o b a l u s e r . ema i l ankan@ludd . l t u . s e
Create a common storage area
I Many sites offer free hosting. (Github, Bitbucket, Ludd)Create an account and a repository there.
I Or create your own on a server. (All you need is a directory allusers can access.)
8 / 27
![Page 9: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/9.jpg)
Your own repository
Create your own repository (on a server):
1 g i t i n i t −−bare −−sha r ed t e s t . g i t2 groupadd t e s t p r o j e c t3 chgrp −R t e s t p r o j e c t t e s t . g i t4 chmod −R 770 t e s t . g i t
9 / 27
![Page 10: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/10.jpg)
To begin putting stuff in there
Prepare a simple repository to upload (on aclient machine.):
1 g i t i n i t t e s t2 cd te s t3 touch README4 g i t add README5 g i t commit −m ’ f i r s t commit ’
10 / 27
![Page 11: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/11.jpg)
Connect with the server for the first time
Bitbucket:
1 g i t remote add o r i g i n h t t p s : // ankaan@b i tbucket . org /ankaan/ t e s t . g i t
Github:
1 g i t remote add o r i g i n g i t@g i t h ub . com : ankaan/ t e s t . g i t
Your own server:
1 g i t remote add o r i g i n ankan@ l o ca l ho s t : t e s t . g i t
Upload:
1 g i t push −u o r i g i n master
11 / 27
![Page 12: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/12.jpg)
Connect more users
To connect more users beyond the first, use:
1 g i t c l o n e ankan@ lo ca l ho s t : t e s t . g i t
12 / 27
![Page 13: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/13.jpg)
Overview
IntroductionIn a world without versioncontrolTypes of version controlThis is git
Getting startedPreparationsYour own repositoryFirst time with a repositoryConnect more users
Using git
Everyday useTagsBranchingUndoA closer look at the historyIgnoring filesGit on Windows
ConclusionSummaryBibliography and linksQuestions and comments
13 / 27
![Page 14: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/14.jpg)
Everyday use
Which commands to you actually need to learn?
add Mark file for saving.
reset Unmark file for saving.
commit Save changes to the log.
status How does the git-repo look? What files have beenchanged?
push Send all committed changes to the shared repository.
pull Download all changes from the shared repository.
checkout Get an old version of a file.
log Show a log over all commits made.
help Show the help for a certain command.
14 / 27
![Page 15: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/15.jpg)
How is data stored in git?
Remote Repository
Local Repository
Staging Area
Working Directory
pull
fetch push
checkout add
commit
15 / 27
![Page 16: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/16.jpg)
Demonstration
Demonstration of the basic concepts.
I Change files.
I Commit.
I Handle conflicts.
I Look in the log.
16 / 27
![Page 17: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/17.jpg)
Tags
What is a tag?
I A named bookmark that points to a specific commit.
Commands to handle tags:
1 g i t tag <name>2 g i t tag3 g i t push −−t ag s
17 / 27
![Page 18: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/18.jpg)
Branches and commits
1
4
3
5
7
2
6
8
masterdevel next-gen
1.0
1.1
18 / 27
![Page 19: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/19.jpg)
How to use branches
Commands:
branch List or create a new branch. (-r to list remotebranches.)
checkout Is used to change branches.
merge Bring in changes from another branch.
Branches are local by default:
1 # Upload and f o l l o w :2 g i t push −u o r i g i n <branch>34 # Fol low a remote branch :5 g i t branch < l o c a l b r a n c h> <remote branch>
19 / 27
![Page 20: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/20.jpg)
Undo
Undo can mean different things:
1 # While s t i l l cod ing :2 g i t checkout < f i l e >3 g i t checkout 502 f cb1 < f i l e >45 # Prepared f o r a commit , but not y e t committed :6 g i t r e s e t HEAD < f i l e >78 # Al r eady committed :9 g i t r e v e r t 502 f cb1
Leave your committed errors in the history!
20 / 27
![Page 21: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/21.jpg)
A closer look at the history
Different ways of looking at the history:
log Show a log of all commits with their comments.
show Show details for a specific commit.
diff Compare different versions of files.
blame Show who last touched a certain row.
21 / 27
![Page 22: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/22.jpg)
Ignoring files
How do you get git to stop listing certain files?
I Create a .gitignore file and list what should be ignored(wildcards are available.)
22 / 27
![Page 23: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/23.jpg)
Git on Windows
What if I use Windows?
I msysgit (installs a shell and works just like on Linux.)
I Git Extensions (a GUI-application.)
I Built into your IDE (Eclipse, IntelliJ Idea, etc.)
I There are GUI programs for other operating systems also.
23 / 27
![Page 24: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/24.jpg)
Overview
IntroductionIn a world without versioncontrolTypes of version controlThis is git
Getting startedPreparationsYour own repositoryFirst time with a repositoryConnect more users
Using git
Everyday useTagsBranchingUndoA closer look at the historyIgnoring filesGit on Windows
ConclusionSummaryBibliography and linksQuestions and comments
24 / 27
![Page 25: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/25.jpg)
Summary
We have seen:
I What you need version control for.
I What git is.
I How to use git.
I Some of the most common problems you can encounter.
25 / 27
![Page 26: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/26.jpg)
Bibliography and links
Guides:
I http://schacon.github.com/git/gittutorial.html
I http://ricroberts.com/articles/
getting-to-grips-with-git-part-1-the-basics
Online hosting:
I http://buck.ludd.ltu.se
I http://gitlab.com
I http://github.com
I http://bitbucket.org
More information:
I http://en.wikipedia.org/wiki/Revision_control
I http://en.wikipedia.org/wiki/Git_(software)26 / 27
![Page 27: Introduction to gitGit on Windows What if I use Windows? I msysgit (installs a shell and works just like on Linux.) I Git Extensions (a GUI-application.) I Built into your IDE (Eclipse,](https://reader030.fdocuments.in/reader030/viewer/2022040621/5f37c3eadb14147878291215/html5/thumbnails/27.jpg)
Questions and comments
?
27 / 27