SlideShare a Scribd company logo
1 of 29
Download to read offline
Mini Git Tutorial
http://git-scm.com/
Cristian Lucchesi <cristian.lucchesi@iit.cnr.it>, @crilucCristian Lucchesi <cristian.lucchesi@iit.cnr.it>, @criluc
https://github.com/criluc/mini-git-tutorialhttps://github.com/criluc/mini-git-tutorial
22 novembre 201222 novembre 2012
Disclaimer
• Tutorial arranged in one day... from a Git end user
• Strongly based on:
o Pro Git book, written by Scott Chacon and published by Apress
is available to read online for free http://git-scm.com/book
Company using Git
Version Control System
• a system that records changes to a file or set of files
over time so that you can recall specific versions later.
• It allows you:
o to revert files back to a previous state
o revert the entire project back to a previous state
o compare changes over time
o see who last modified something that might be
causing a problem
o who introduced an issue and when, and more.
o using a VCS also generally means that if you screw
things up or lose files, you can easily recover
o you get all this for very little overhead.
Centralized VCS (CVS,SVN..)
• have a single server that
contains all the versioned files
• clients check out files from that
central place
• everyone knows to a certain
degree what everyone else on
the project is doing
• administrators have fine-grained
control over who can do what
• it’s far easier to administer
• single point of failure that the
centralized server represents
• whenever you have the entire
history of the project in a single
place, you risk losing everything
Distribuited VCS (Git,
Mercurial, Bazar, ...)
• clients don’t just check out the latest
snapshot of the files: they fully mirror
the repository
• if any server dies, and these systems
were collaborating via it, any of the
client repositories can be copied back
up to the server to restore it
• deal pretty well with having several
remote repositories it can work with
• allows you to set up several types
of workflows that aren’t possible
in centralized systems, such as
hierarchical models
• you need a tutorial like this to
use it :-)
Short History of GIT
• Developed since 2005 from Linux development
community (and in particular Linus Torvalds, the
creator of Linux)
• the goals of the new system were:
o Speed
o Simple design
o Strong support for non-linear development
(thousands of parallel branches)
o Fully distributed
o Able to handle large projects like the Linux kernel
efficiently (speed and data size)
Git Basics
• other systems: store information as a list of file-based changes
• Git: its data more like a set of snapshots of a mini filesystem
Git Has Integrity
• everything is check-summed before it is stored
and is then referred to by that checksum
• checksumming using a SHA-1 hash
• is a 40-character string composed of hexadecimal
characters (0–9 and a–f) and calculated based on
the contents of a file or directory structure in Git
• something like this:
o 24b9da6552252987aa493b52f8696cd6d3b00373
• Git stores everything not by file name but in the
Git database addressable by the hash value of its
contents
Three state
• Git has three main states that your files can reside in:
o committed, modified, and staged.
• Committed means that the data is safely stored in
your local database
• Modified means that you have changed the file but
have not committed it to your database yet
• Staged means that you have marked a modified file
in its current version to go into your next commit
snapshot
Three main area
• Git directory
o is where Git stores the metadata and object database for
your project.
o the most important part of Git, and it is what is copied
when you clone a repository from another computer
• working directory
o is a single checkout of one version of the project. These
files are pulled out of the compressed database in the
Git directory and placed on disk for you to use or modify
• staging area (index)
o is a simple file, generally contained in your Git directory,
that stores information about what will go into your next
commit
Local operations
Basic Git Workflow
1) You modify files in your working directory
2) You stage the files
adding snapshots of them to your staging area
3) You do a commit
which takes the files as they are in the staging area and stores
that snapshot permanently to your Git directory.
• If a particular version of a file:
o is in the git directory, it’s considered committed
o If it’s modified but has been added to the staging area, it is
staged
o if it was changed since it was checked out but has not been
staged, it is modified
Installing Git
• On a Debian-based distribution like Ubuntu
o $ apt-get install git
• On Mac, there are two easy ways to install Git
o use the graphical Git installer
• http://code.google.com/p/git-osx-installer
o via MacPorts (http://www.macports.org)
• $ sudo port install git-core +svn +doc +bash_completion
+gitweb
• On Windows, the msysGit project has one of the easier
installation procedures (download the installer exe file)
o http://code.google.com/p/msysgit
$ git config
• get and set configuration variables
o /etc/gitconfig
• contains values for every user on the system
and all their repositories
• if you pass the option --system to git config, it
reads and writes from this file specifically
o ~/.gitconfig
• specific to your user. Use –-global option to read
and write to this file
o .git/config
• config file in the git directory, specific to that
single repository
First time Git setup
• Your Identity
o $ git config --global user.name "Cristian Lucchesi"
o $ git config --global user.email cristian.lucchesi@iit.cnr.it
• Your Editor
o $ git config --global core.editor emacs
• Your Diff Tool
o $ git config --global merge.tool vimdiff
• Checking Your Settings
o $ git config –list
user.name=Cristian Lucchesi
user.email=cristian.lucchesi@iit.cnr.it
…..
Getting help
• In 3 different ways
o $ git help <verb>
o $ git <verb> --help
o $ man git-<verb>
• For example
o $ git help config
Getting a Git repository
• take an existing project or directory and import it
o $ git init
• creates .git dir containing a repository skeleton
• nothing in your project is tracked yet
• $ git add *.py to start tracking files
• clone an existing Git repository from another server.
o $ git clone git://github.com/schacon/grit.git
• creates a directory named grit
• initializes a .git directory inside it
• pulls down all the data for that repository
• checks out a working copy of the latest version
Recording changes
• You need to make some changes and commit
snapshots of those changes into your repository each
time the project reaches a state you want to record.
• each file in your working directory can be in one of two
states: tracked or untracked
• tracked:
o files that were in the last snapshot;
o they can be unmodified, modified, or staged
• untracked:
o any files in your working directory that
• were not in your last snapshot
• are not in your staging area
File status lifecicle
Hands
on
Git
Undoing Things
• Changing Your Last Commit
o $ git commit –amend
• as an example, if you commit and then realize
you forgot to stage the changes in a file you
wanted to add to this commit:
– $ git commit -m 'initial commit'
– $ git add forgotten_file
– $ git commit --amend
Undoing Things (cont)
• Unstaging a Staged File
o git reset HEAD <file>...
• or example, let’s say you’ve changed two files
and want to commit them as two separate
changes, but you accidentally type git add * and
stage them both
– $ git reset HEAD benchmarks.py
» the benchmarks.py file is modified but
once again unstaged.
Undoing Things (cont)
• Unmodifying a Modified File
o git checkout -- <file>...
• can you easily unmodify a file revert it back to
what it looked like when:
– you last committed
– or initially cloned
– or however you got it into your working
directory
• git status tells you how to do that, too
Working with Remotes
• Remote repositories are versions of your
project that are hosted on the Internet or
network somewhere
• you can have several of them
• $ git remote
origin
o origin is the default name Git gives to the
server you cloned from
• $ git remote -v
origin git://github.com/schacon/ticgit.git
Git repository objects
• single commit repository
• Git object data for multiple
commits
Git branching
• Branch pointing into the
commit data’s history
• the branch that HEAD
points to moves forward with each commit
GIT basic HTTP Auth
• at least on Linux the HTTP Basic Auth
doesn't work well
• Workaround:
o create a .netrc file in your home dir
$ cat ~/.netrc
machine wiki.iit.cnr.it
login your-username
password your-password
This tutorial is on github
http://bit.ly/UJNcI1

More Related Content

What's hot

Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started PresentationNap Ramirez
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015mwrather
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 

What's hot (20)

Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
GitHub Presentation
GitHub PresentationGitHub Presentation
GitHub Presentation
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git 101
Git 101Git 101
Git 101
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
Git basics
Git basicsGit basics
Git basics
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Git training
Git trainingGit training
Git training
 

Viewers also liked

Using Git with Rational Team Concert and Rational ClearCase in enterprise env...
Using Git with Rational Team Concert and Rational ClearCase in enterprise env...Using Git with Rational Team Concert and Rational ClearCase in enterprise env...
Using Git with Rational Team Concert and Rational ClearCase in enterprise env...Bartosz Chrabski
 
Linux Day 2015 Genova
Linux Day 2015 GenovaLinux Day 2015 Genova
Linux Day 2015 Genovamperrando
 
Introduzione a GIT - Laboratorio di Web Design 2014/15
Introduzione a GIT - Laboratorio di Web Design 2014/15Introduzione a GIT - Laboratorio di Web Design 2014/15
Introduzione a GIT - Laboratorio di Web Design 2014/15Giovanni Buffa
 
Sys05 uso consapevole di git - beyond the basic
Sys05   uso consapevole di git - beyond the basicSys05   uso consapevole di git - beyond the basic
Sys05 uso consapevole di git - beyond the basicDotNetCampus
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹Max Ma
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshellNelson Tai
 
Software Project Management using Redmine
Software Project Management using RedmineSoftware Project Management using Redmine
Software Project Management using RedmineRitesh Tamrakar
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVNPHPBelgium
 

Viewers also liked (20)

Git best practices
Git best practicesGit best practices
Git best practices
 
Git e Git Flow
Git e Git Flow Git e Git Flow
Git e Git Flow
 
Using Git with Rational Team Concert and Rational ClearCase in enterprise env...
Using Git with Rational Team Concert and Rational ClearCase in enterprise env...Using Git with Rational Team Concert and Rational ClearCase in enterprise env...
Using Git with Rational Team Concert and Rational ClearCase in enterprise env...
 
GitSlides
GitSlidesGitSlides
GitSlides
 
Linux Day 2015 Genova
Linux Day 2015 GenovaLinux Day 2015 Genova
Linux Day 2015 Genova
 
GITT (part 1 of 2)
GITT (part 1 of 2)GITT (part 1 of 2)
GITT (part 1 of 2)
 
Introduzione a GIT - Laboratorio di Web Design 2014/15
Introduzione a GIT - Laboratorio di Web Design 2014/15Introduzione a GIT - Laboratorio di Web Design 2014/15
Introduzione a GIT - Laboratorio di Web Design 2014/15
 
Sys05 uso consapevole di git - beyond the basic
Sys05   uso consapevole di git - beyond the basicSys05   uso consapevole di git - beyond the basic
Sys05 uso consapevole di git - beyond the basic
 
Perchè Git?
Perchè Git?Perchè Git?
Perchè Git?
 
Git–SVN
Git–SVNGit–SVN
Git–SVN
 
Introduzione a git
Introduzione a gitIntroduzione a git
Introduzione a git
 
Introduzione a Git
Introduzione a GitIntroduzione a Git
Introduzione a Git
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Anatomia di un progetto open-source
Anatomia di un progetto open-sourceAnatomia di un progetto open-source
Anatomia di un progetto open-source
 
Controllo di versione e Git
Controllo di versione e GitControllo di versione e Git
Controllo di versione e Git
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Software Project Management using Redmine
Software Project Management using RedmineSoftware Project Management using Redmine
Software Project Management using Redmine
 
Git for dummies
Git for dummiesGit for dummies
Git for dummies
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVN
 

Similar to Mini git tutorial

Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with GitThings Lab
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptxtnscharishma
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
 
Git is a distributed version control system .
Git is a distributed version control system .Git is a distributed version control system .
Git is a distributed version control system .HELLOWorld889594
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 

Similar to Mini git tutorial (20)

Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Learning git
Learning gitLearning git
Learning git
 
Git basics
Git basicsGit basics
Git basics
 
Git hub
Git hubGit hub
Git hub
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Git is a distributed version control system .
Git is a distributed version control system .Git is a distributed version control system .
Git is a distributed version control system .
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
GIT-FirstPart.ppt
GIT-FirstPart.pptGIT-FirstPart.ppt
GIT-FirstPart.ppt
 

Recently uploaded

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 

Recently uploaded (20)

2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 

Mini git tutorial

  • 1. Mini Git Tutorial http://git-scm.com/ Cristian Lucchesi <cristian.lucchesi@iit.cnr.it>, @crilucCristian Lucchesi <cristian.lucchesi@iit.cnr.it>, @criluc https://github.com/criluc/mini-git-tutorialhttps://github.com/criluc/mini-git-tutorial 22 novembre 201222 novembre 2012
  • 2. Disclaimer • Tutorial arranged in one day... from a Git end user • Strongly based on: o Pro Git book, written by Scott Chacon and published by Apress is available to read online for free http://git-scm.com/book
  • 4. Version Control System • a system that records changes to a file or set of files over time so that you can recall specific versions later. • It allows you: o to revert files back to a previous state o revert the entire project back to a previous state o compare changes over time o see who last modified something that might be causing a problem o who introduced an issue and when, and more. o using a VCS also generally means that if you screw things up or lose files, you can easily recover o you get all this for very little overhead.
  • 5. Centralized VCS (CVS,SVN..) • have a single server that contains all the versioned files • clients check out files from that central place • everyone knows to a certain degree what everyone else on the project is doing • administrators have fine-grained control over who can do what • it’s far easier to administer • single point of failure that the centralized server represents • whenever you have the entire history of the project in a single place, you risk losing everything
  • 6. Distribuited VCS (Git, Mercurial, Bazar, ...) • clients don’t just check out the latest snapshot of the files: they fully mirror the repository • if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it • deal pretty well with having several remote repositories it can work with • allows you to set up several types of workflows that aren’t possible in centralized systems, such as hierarchical models • you need a tutorial like this to use it :-)
  • 7. Short History of GIT • Developed since 2005 from Linux development community (and in particular Linus Torvalds, the creator of Linux) • the goals of the new system were: o Speed o Simple design o Strong support for non-linear development (thousands of parallel branches) o Fully distributed o Able to handle large projects like the Linux kernel efficiently (speed and data size)
  • 8. Git Basics • other systems: store information as a list of file-based changes • Git: its data more like a set of snapshots of a mini filesystem
  • 9. Git Has Integrity • everything is check-summed before it is stored and is then referred to by that checksum • checksumming using a SHA-1 hash • is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git • something like this: o 24b9da6552252987aa493b52f8696cd6d3b00373 • Git stores everything not by file name but in the Git database addressable by the hash value of its contents
  • 10. Three state • Git has three main states that your files can reside in: o committed, modified, and staged. • Committed means that the data is safely stored in your local database • Modified means that you have changed the file but have not committed it to your database yet • Staged means that you have marked a modified file in its current version to go into your next commit snapshot
  • 11. Three main area • Git directory o is where Git stores the metadata and object database for your project. o the most important part of Git, and it is what is copied when you clone a repository from another computer • working directory o is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify • staging area (index) o is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit
  • 13. Basic Git Workflow 1) You modify files in your working directory 2) You stage the files adding snapshots of them to your staging area 3) You do a commit which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. • If a particular version of a file: o is in the git directory, it’s considered committed o If it’s modified but has been added to the staging area, it is staged o if it was changed since it was checked out but has not been staged, it is modified
  • 14. Installing Git • On a Debian-based distribution like Ubuntu o $ apt-get install git • On Mac, there are two easy ways to install Git o use the graphical Git installer • http://code.google.com/p/git-osx-installer o via MacPorts (http://www.macports.org) • $ sudo port install git-core +svn +doc +bash_completion +gitweb • On Windows, the msysGit project has one of the easier installation procedures (download the installer exe file) o http://code.google.com/p/msysgit
  • 15. $ git config • get and set configuration variables o /etc/gitconfig • contains values for every user on the system and all their repositories • if you pass the option --system to git config, it reads and writes from this file specifically o ~/.gitconfig • specific to your user. Use –-global option to read and write to this file o .git/config • config file in the git directory, specific to that single repository
  • 16. First time Git setup • Your Identity o $ git config --global user.name "Cristian Lucchesi" o $ git config --global user.email cristian.lucchesi@iit.cnr.it • Your Editor o $ git config --global core.editor emacs • Your Diff Tool o $ git config --global merge.tool vimdiff • Checking Your Settings o $ git config –list user.name=Cristian Lucchesi user.email=cristian.lucchesi@iit.cnr.it …..
  • 17. Getting help • In 3 different ways o $ git help <verb> o $ git <verb> --help o $ man git-<verb> • For example o $ git help config
  • 18. Getting a Git repository • take an existing project or directory and import it o $ git init • creates .git dir containing a repository skeleton • nothing in your project is tracked yet • $ git add *.py to start tracking files • clone an existing Git repository from another server. o $ git clone git://github.com/schacon/grit.git • creates a directory named grit • initializes a .git directory inside it • pulls down all the data for that repository • checks out a working copy of the latest version
  • 19. Recording changes • You need to make some changes and commit snapshots of those changes into your repository each time the project reaches a state you want to record. • each file in your working directory can be in one of two states: tracked or untracked • tracked: o files that were in the last snapshot; o they can be unmodified, modified, or staged • untracked: o any files in your working directory that • were not in your last snapshot • are not in your staging area
  • 22. Undoing Things • Changing Your Last Commit o $ git commit –amend • as an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit: – $ git commit -m 'initial commit' – $ git add forgotten_file – $ git commit --amend
  • 23. Undoing Things (cont) • Unstaging a Staged File o git reset HEAD <file>... • or example, let’s say you’ve changed two files and want to commit them as two separate changes, but you accidentally type git add * and stage them both – $ git reset HEAD benchmarks.py » the benchmarks.py file is modified but once again unstaged.
  • 24. Undoing Things (cont) • Unmodifying a Modified File o git checkout -- <file>... • can you easily unmodify a file revert it back to what it looked like when: – you last committed – or initially cloned – or however you got it into your working directory • git status tells you how to do that, too
  • 25. Working with Remotes • Remote repositories are versions of your project that are hosted on the Internet or network somewhere • you can have several of them • $ git remote origin o origin is the default name Git gives to the server you cloned from • $ git remote -v origin git://github.com/schacon/ticgit.git
  • 26. Git repository objects • single commit repository • Git object data for multiple commits
  • 27. Git branching • Branch pointing into the commit data’s history • the branch that HEAD points to moves forward with each commit
  • 28. GIT basic HTTP Auth • at least on Linux the HTTP Basic Auth doesn't work well • Workaround: o create a .netrc file in your home dir $ cat ~/.netrc machine wiki.iit.cnr.it login your-username password your-password
  • 29. This tutorial is on github http://bit.ly/UJNcI1