SlideShare a Scribd company logo
1 of 22
Basics of Git
A distributed version control system
Presented by Ahmed Al-sabsab
*
Version control systems
■ Version control (or revision control, or source control) is all
about managing multiple versions of documents, programs, web
sites, etc.
■ Almost all “real” projects use some kind of version control
■ Essential for team projects, but also very useful for individual projects
■ Some well-known version control systems are CVS, Subversion,
Mercurial, and Git
■ CVS and Subversion use a “central” repository; users “check out” files,
work on them, and “check them in”
■ Mercurial and Git treat all repositories as equal
■ Distributed systems like Git are newer and are gradually
replacing centralized systems like CVS and Subversion
2
History of Git
■ Git was created by Linus Torvalds in 2005 for development of
the Linux kernel, with other kernel developers contributing to its
initial development.
■ Git is free and open-source software distributed under GNU
General Public License Version 2.
3
Why version control?
■ For working by yourself:
■ Gives you a “time machine” for going back to earlier versions
■ Gives you great support for different versions (standalone,
web app, etc.) of the same basic project
■ For working with others:
■ Greatly simplifies concurrent work, merging changes
■ For getting an internship or job:
■ Any company with a clue uses some kind of version control
■ Companies without a clue are bad places to work
4
Why Git?
■ Git has many advantages over earlier systems such as
CVS and Subversion
■ More efficient, better workflow, etc.
■ Git now is the main tool used for the modern automatic
integration and deployment technology DevOps
(CI/CD).
5
Download and install Git
■ There are online materials that are better than any that I could
provide
■ Here’s the standard one:
http://git-scm.com/downloads
■ Here’s one from StackExchange:
http://stackoverflow.com/questions/315911/git-for-beginners-the-
definitive-practical-guide#323764
6
Introduce yourself to Git
■ Enter these lines (with appropriate changes):
■ git config --global user.name "John Smith"
■ git config --global user.email jsmith@seas.upenn.edu
■ You only need to do this once
■ If you want to use a different name/email address for a
particular project, you can change it for just that project
■ cd to the project directory
■ Use the above commands, but leave out the –global
■ (Example)
7
Create and fill a repository
1. cd to the project directory you want to use
2. Type in git init
■ This creates the repository (a directory named .git)
■ You seldom (if ever) need to look inside this directory
3. Type in git add .
■ The period at the end is part of this command!
■ Period means “this directory”
■ This adds all your current files to the repository
4. Type in git commit –m "Initial commit"
■ You can use a different commit message, if you like
■ (Example)
8
Why commands?
■ You should at least know the basic commands:
■ To be able to fix accidental git problems.
■ Git is very big and flexible technology that has an advanced
commands that are rarely used and can’t be done with git GUI
softwares.
■ You should be able to search for and use commands that
solves your problem
9
Clone a repository from elsewhere
■ git clone URL
■ git clone URL mypath
■ These make an exact copy of the repository at the given URL
■ git clone git://github.com/rest_of_path/file.git
■ Github is the most popular (free) public repository
■ All repositories are equal
■ But you can treat some particular repository (such as one on Github) as
the “master” directory
■ Typically, each team member works in his/her own repository,
and “merges” with other repositories as appropriate
■ (Example)
10
The repository
■ Your top-level working directory contains everything about
your project
■ The working directory probably contains many subdirectories—source
code, binaries, documentation, data files, etc.
■ One of these subdirectories, named .git, is your repository
■ At any time, you can take a “snapshot” of everything (or selected
things) in your project directory, and put it in your repository
■ This “snapshot” is called a commit object
■ The commit object contains (1) a set of files, (2) references to the
“parents” of the commit object, and (3) a unique “SHA1” name
■ Commit objects do not require huge amounts of memory
■ You can work as much as you like in your working directory, but
the repository isn’t updated until you commit something
11
init and the .git repository
■ When you said git init in your project directory, or
when you cloned an existing project, you created a
repository
■ The repository is a subdirectory named .git containing
various files
■ The dot indicates a “hidden” directory
■ You do not work directly with the contents of that directory;
various git commands do that for you
■ You do need a basic understanding of what is in the repository
12
Making commits
■ You do your work in your project directory, as usual
■ If you create new files and/or folders, they are not tracked by Git unless you
ask it to do so
■ git add newFile1 newFolder1 newFolder2 newFile2
■ Committing makes a “snapshot” of everything being tracked into your
repository
■ A message telling what you have done is required
■ git commit –m “Uncrevulated the conundrum bar”
■ git commit
■ This version opens an editor for you the enter the message
■ To finish, save and quit the editor
■ Format of the commit message
■ One line containing the complete summary
■ If more than one line, the second line must be blank
■ (Example)
13
Commits and graphs
■ A commit is when you tell git that a change (or addition) you
have made is ready to be included in the project
■ When you commit your change to git, it creates a commit object
■ A commit object represents the complete state of the project, including all
the files in the project
■ The very first commit object has no “parents”
■ Usually, you take some commit object, make some changes, and create a
new commit object; the original commit object is the parent of the new
commit object
■ Hence, most commit objects have a single parent
■ You can also merge two commit objects to form a new one
■ The new commit object has two parents
■ Hence, commit objects form a directed graph
■ Git is all about using and manipulating this graph
14
Working with your own repository
■ A head is a reference to a commit object
■ The “current head” is called HEAD (all caps)
■ Usually, you will take HEAD (the current commit object), make
some changes to it, and commit the changes, creating a new
current commit object
■ This results in a linear graph: A 🡪 B 🡪 C 🡪 …🡪 HEAD
■ You can also take any previous commit object, make changes to
it, and commit those changes
■ This creates a branch in the graph of commit objects
■ You can merge any previous commit objects
■ This joins branches in the commit graph
15
Commit messages
■ In git, “Commits are cheap.” Do them often.
■ When you commit, you must provide a one-line
message stating what you have done
■ Terrible message: “Fixed a bunch of things”
■ Better message: “Corrected the calculation of median scores”
■ Commit messages can be very helpful, to yourself as
well as to your team members
■ You can’t say much in one line, so commit often
16
Choose an editor
■ When you “commit,” git will require you to type in a
commit message
■ For longer commit messages, you will use an editor
■ The default editor is probably vim
■ To change the default editor:
■ git config --global core.editor /path/to/editor
■ You may also want to turn on colors:
■ git config --global color.ui auto
17
Working with others
■ All repositories are equal, but it is convenient to have one central
repository in the cloud
■ Here’s what you normally do:
■ Download the current HEAD from the central repository
■ Make your changes
■ Commit your changes to your local repository
■ Check to make sure someone else on your team hasn’t updated the central
repository since you got it git pull
■ Get others commits if they exist (git pull – git fitch)
■ Upload your changes to the central repository (git push)
■ If the central repository has changed since you got it:
■ It is your responsibility to merge your two versions
■ This is a strong incentive to commit and upload often!
■ Git can often do this for you, if there aren’t incompatible changes
18
Typical workflow
■ git pull remote_repository
■ Get changes from a remote repository and merge them into
your own repository
■ git status
■ See what Git thinks is going on
■ Use this frequently!
■ Work on your files (remember to add any new ones)
■ git commit –m “What I did”
■ git push
■ (Example)
19
Multiple versions
20
Initial commit
Second commit
Third commit
Ali gets a copy
Fourth commit
Merge
Ali’s commit
21
Keeping it simple
■ If you:
■ Make sure you are current with the central repository
■ Make some improvements to your code
■ Update the central repository before anyone else does
■ Then you don’t have to worry about resolving conflicts or
working with multiple branches
■ All the complexity in git comes from dealing with these
■ Therefore:
■ Make sure you are up-to-date before starting to work
■ Commit and update the central repository frequently
22

More Related Content

What's hot

Git for uninitiated
Git for uninitiatedGit for uninitiated
Git for uninitiatedJohn C. Chan
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open SourceLorna Mitchell
 
Evolution of Version Control In Open Source
Evolution of Version Control In Open SourceEvolution of Version Control In Open Source
Evolution of Version Control In Open SourceChris Aniszczyk
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administrationShawn Doyle
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and githubAderemi Dadepo
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHubDSCVSSUT
 
Github Case Study By Amil Ali
Github Case Study By Amil AliGithub Case Study By Amil Ali
Github Case Study By Amil AliAmilAli1
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentalsRajKharvar
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?Leonid Mamchenkov
 

What's hot (20)

Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
 
Git 101
Git 101Git 101
Git 101
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git for uninitiated
Git for uninitiatedGit for uninitiated
Git for uninitiated
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
Evolution of Version Control In Open Source
Evolution of Version Control In Open SourceEvolution of Version Control In Open Source
Evolution of Version Control In Open Source
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Hello, Git!
Hello, Git!Hello, Git!
Hello, Git!
 
Github Case Study By Amil Ali
Github Case Study By Amil AliGithub Case Study By Amil Ali
Github Case Study By Amil Ali
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 

Similar to Basics of git

A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfbadrfathallah2
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfAmarnadh36
 
ePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version ControlePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version ControlGiuseppe Masetti
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
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
 
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
 

Similar to Basics of git (20)

finall_(1).pptx
finall_(1).pptxfinall_(1).pptx
finall_(1).pptx
 
git.ppt
git.pptgit.ppt
git.ppt
 
Git
GitGit
Git
 
Git
GitGit
Git
 
Source control
Source controlSource control
Source control
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
 
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
 
Git hub
Git hubGit hub
Git hub
 
ePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version ControlePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version Control
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
setting up a repository using GIT
setting up a repository using GITsetting up a repository using GIT
setting up a repository using GIT
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
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
 
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
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

Basics of git

  • 1. Basics of Git A distributed version control system Presented by Ahmed Al-sabsab *
  • 2. Version control systems ■ Version control (or revision control, or source control) is all about managing multiple versions of documents, programs, web sites, etc. ■ Almost all “real” projects use some kind of version control ■ Essential for team projects, but also very useful for individual projects ■ Some well-known version control systems are CVS, Subversion, Mercurial, and Git ■ CVS and Subversion use a “central” repository; users “check out” files, work on them, and “check them in” ■ Mercurial and Git treat all repositories as equal ■ Distributed systems like Git are newer and are gradually replacing centralized systems like CVS and Subversion 2
  • 3. History of Git ■ Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. ■ Git is free and open-source software distributed under GNU General Public License Version 2. 3
  • 4. Why version control? ■ For working by yourself: ■ Gives you a “time machine” for going back to earlier versions ■ Gives you great support for different versions (standalone, web app, etc.) of the same basic project ■ For working with others: ■ Greatly simplifies concurrent work, merging changes ■ For getting an internship or job: ■ Any company with a clue uses some kind of version control ■ Companies without a clue are bad places to work 4
  • 5. Why Git? ■ Git has many advantages over earlier systems such as CVS and Subversion ■ More efficient, better workflow, etc. ■ Git now is the main tool used for the modern automatic integration and deployment technology DevOps (CI/CD). 5
  • 6. Download and install Git ■ There are online materials that are better than any that I could provide ■ Here’s the standard one: http://git-scm.com/downloads ■ Here’s one from StackExchange: http://stackoverflow.com/questions/315911/git-for-beginners-the- definitive-practical-guide#323764 6
  • 7. Introduce yourself to Git ■ Enter these lines (with appropriate changes): ■ git config --global user.name "John Smith" ■ git config --global user.email jsmith@seas.upenn.edu ■ You only need to do this once ■ If you want to use a different name/email address for a particular project, you can change it for just that project ■ cd to the project directory ■ Use the above commands, but leave out the –global ■ (Example) 7
  • 8. Create and fill a repository 1. cd to the project directory you want to use 2. Type in git init ■ This creates the repository (a directory named .git) ■ You seldom (if ever) need to look inside this directory 3. Type in git add . ■ The period at the end is part of this command! ■ Period means “this directory” ■ This adds all your current files to the repository 4. Type in git commit –m "Initial commit" ■ You can use a different commit message, if you like ■ (Example) 8
  • 9. Why commands? ■ You should at least know the basic commands: ■ To be able to fix accidental git problems. ■ Git is very big and flexible technology that has an advanced commands that are rarely used and can’t be done with git GUI softwares. ■ You should be able to search for and use commands that solves your problem 9
  • 10. Clone a repository from elsewhere ■ git clone URL ■ git clone URL mypath ■ These make an exact copy of the repository at the given URL ■ git clone git://github.com/rest_of_path/file.git ■ Github is the most popular (free) public repository ■ All repositories are equal ■ But you can treat some particular repository (such as one on Github) as the “master” directory ■ Typically, each team member works in his/her own repository, and “merges” with other repositories as appropriate ■ (Example) 10
  • 11. The repository ■ Your top-level working directory contains everything about your project ■ The working directory probably contains many subdirectories—source code, binaries, documentation, data files, etc. ■ One of these subdirectories, named .git, is your repository ■ At any time, you can take a “snapshot” of everything (or selected things) in your project directory, and put it in your repository ■ This “snapshot” is called a commit object ■ The commit object contains (1) a set of files, (2) references to the “parents” of the commit object, and (3) a unique “SHA1” name ■ Commit objects do not require huge amounts of memory ■ You can work as much as you like in your working directory, but the repository isn’t updated until you commit something 11
  • 12. init and the .git repository ■ When you said git init in your project directory, or when you cloned an existing project, you created a repository ■ The repository is a subdirectory named .git containing various files ■ The dot indicates a “hidden” directory ■ You do not work directly with the contents of that directory; various git commands do that for you ■ You do need a basic understanding of what is in the repository 12
  • 13. Making commits ■ You do your work in your project directory, as usual ■ If you create new files and/or folders, they are not tracked by Git unless you ask it to do so ■ git add newFile1 newFolder1 newFolder2 newFile2 ■ Committing makes a “snapshot” of everything being tracked into your repository ■ A message telling what you have done is required ■ git commit –m “Uncrevulated the conundrum bar” ■ git commit ■ This version opens an editor for you the enter the message ■ To finish, save and quit the editor ■ Format of the commit message ■ One line containing the complete summary ■ If more than one line, the second line must be blank ■ (Example) 13
  • 14. Commits and graphs ■ A commit is when you tell git that a change (or addition) you have made is ready to be included in the project ■ When you commit your change to git, it creates a commit object ■ A commit object represents the complete state of the project, including all the files in the project ■ The very first commit object has no “parents” ■ Usually, you take some commit object, make some changes, and create a new commit object; the original commit object is the parent of the new commit object ■ Hence, most commit objects have a single parent ■ You can also merge two commit objects to form a new one ■ The new commit object has two parents ■ Hence, commit objects form a directed graph ■ Git is all about using and manipulating this graph 14
  • 15. Working with your own repository ■ A head is a reference to a commit object ■ The “current head” is called HEAD (all caps) ■ Usually, you will take HEAD (the current commit object), make some changes to it, and commit the changes, creating a new current commit object ■ This results in a linear graph: A 🡪 B 🡪 C 🡪 …🡪 HEAD ■ You can also take any previous commit object, make changes to it, and commit those changes ■ This creates a branch in the graph of commit objects ■ You can merge any previous commit objects ■ This joins branches in the commit graph 15
  • 16. Commit messages ■ In git, “Commits are cheap.” Do them often. ■ When you commit, you must provide a one-line message stating what you have done ■ Terrible message: “Fixed a bunch of things” ■ Better message: “Corrected the calculation of median scores” ■ Commit messages can be very helpful, to yourself as well as to your team members ■ You can’t say much in one line, so commit often 16
  • 17. Choose an editor ■ When you “commit,” git will require you to type in a commit message ■ For longer commit messages, you will use an editor ■ The default editor is probably vim ■ To change the default editor: ■ git config --global core.editor /path/to/editor ■ You may also want to turn on colors: ■ git config --global color.ui auto 17
  • 18. Working with others ■ All repositories are equal, but it is convenient to have one central repository in the cloud ■ Here’s what you normally do: ■ Download the current HEAD from the central repository ■ Make your changes ■ Commit your changes to your local repository ■ Check to make sure someone else on your team hasn’t updated the central repository since you got it git pull ■ Get others commits if they exist (git pull – git fitch) ■ Upload your changes to the central repository (git push) ■ If the central repository has changed since you got it: ■ It is your responsibility to merge your two versions ■ This is a strong incentive to commit and upload often! ■ Git can often do this for you, if there aren’t incompatible changes 18
  • 19. Typical workflow ■ git pull remote_repository ■ Get changes from a remote repository and merge them into your own repository ■ git status ■ See what Git thinks is going on ■ Use this frequently! ■ Work on your files (remember to add any new ones) ■ git commit –m “What I did” ■ git push ■ (Example) 19
  • 20. Multiple versions 20 Initial commit Second commit Third commit Ali gets a copy Fourth commit Merge Ali’s commit
  • 21. 21
  • 22. Keeping it simple ■ If you: ■ Make sure you are current with the central repository ■ Make some improvements to your code ■ Update the central repository before anyone else does ■ Then you don’t have to worry about resolving conflicts or working with multiple branches ■ All the complexity in git comes from dealing with these ■ Therefore: ■ Make sure you are up-to-date before starting to work ■ Commit and update the central repository frequently 22