SlideShare a Scribd company logo
Git
A distributed version control system
Powerpoint credited to University of PA
And modified by Pepper
31-Jul-23
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 Mercurial and Git are newer and are
gradually replacing centralized systems like CVS and Subversion
2
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
3
Download and install Git
 There are online materials that are better than any that I could
provide
 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
 Install Git on your machine from http://git-scm.com/downloads
 Accept context menu items
 Git access:
 Right click from windows explorer
 gitBash to enter commands
4
Introduce yourself to Git
 Start git / gitBash
 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
5
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 /usr/bin/vim
 You may also want to turn on colors:
 git config --global color.ui auto
 See your options:
 git config -l
6
Your repositories
 We have created 6 class repositories on panther, and
here are their paths.

ssh://user_name@panther.adelphi.edu/opt/git/csc271books.git

ssh://user_name@panther.adelphi.edu/opt/git/csc271tv.git

ssh://user_name@panther.adelphi.edu/opt/git/csc271store.git

ssh://user_name@panther.adelphi.edu/opt/git/csc271movies1.git

ssh://user_name@panther.adelphi.edu/opt/git/csc271games1.git

ssh://user_name@panther.adelphi.edu/opt/git/csc271movies2.git

Prior class: csc440Spring14r1

Use instructions to follow
7
Using your repositories on panther
 Get the files from your repository before starting
 Make a local respository as a clone of master
 git clone /opt/git/csc271books
 See all the contents of the folder
 ls -a to see the .git folder.
 Make changes
 See what changed
 git diff
 Stage changes
 git add –all (or particular files)
 git diff –cached
 Still only in your repository
8
Using your repository
 Put changes back up into repository
 Commit your staged changes in your repository
 git commit -m "the reason for the change"
 Update the respository:
 git push origin
 See what is on the repository
 git remote
 Get what is on repository
 git pull
 If it says to resolve manually, just vi that file and see the head
which is yours
9
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
 git add –-all (or just changes)
 git commit –m “What I did”
 git push
10
Helpful gitBash commands
 Show staged differences: git diff -- cached
 Show status : git status
 Show branches: git branch
 See history: git log
 Checkout a branch: git checkout branch
 Fetch so you can look but maybe not take: git fetch
 Pull will fetch and merge with what you have: git merge
11
Git log commands
 git log
 --pretty=oneline --max-count=2 git log
 --pretty=oneline --since='5 minutes ago' git log
 --pretty=oneline --until='5 minutes ago' git log
 --pretty=oneline --author=<your name> git log
 --pretty=oneline –all
12
Git log pretty
 git log --pretty=format:"%h %ad | %s%d [%an]" --graph --
date=short
 --pretty="..." defines the output format.
 %h is the abbreviated hash of the commit
 %d commit decorations (e.g. branch heads or tags)
 %ad is the commit date
 %s is the comment
 %an is the name of the author
 --graph tells git to display the commit tree in the form of
an ASCII graph layout
 --date=short keeps the date format short and nice
13
Good aliases
 alias gs='git status '
 alias ga='git add '
 alias gb='git branch '
 alias gc='git commit'
 alias gd='git diff'
 alias go='git checkout '
 alias gk='gitk --all&'
 alias gx='gitx --all'
 alias got='git '
 alias get='git '
14

More Related Content

Similar to git2.ppt

Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Git
GitGit
Git
GitGit
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
Nyros Technologies
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
GDSCGHRIETNagpur
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 
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
PouriaQashqai1
 
Git & Github
Git & GithubGit & Github
Git & Github
Aman Lalpuria
 
Git
GitGit
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting StartedWildan Maulana
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
AliaaTarek5
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
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
Geoff Hoffman
 

Similar to git2.ppt (20)

Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git
GitGit
Git
 
Git
GitGit
Git
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
git.ppt
git.pptgit.ppt
git.ppt
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
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 & Github
Git & GithubGit & Github
Git & Github
 
Git
GitGit
Git
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 
Git Training
Git TrainingGit Training
Git Training
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Git hub
Git hubGit hub
Git hub
 
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
 

Recently uploaded

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
amberjdewit93
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
datarid22
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
SriSurya50
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

git2.ppt

  • 1. Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 31-Jul-23
  • 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 Mercurial and Git are newer and are gradually replacing centralized systems like CVS and Subversion 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 3
  • 4. Download and install Git  There are online materials that are better than any that I could provide  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  Install Git on your machine from http://git-scm.com/downloads  Accept context menu items  Git access:  Right click from windows explorer  gitBash to enter commands 4
  • 5. Introduce yourself to Git  Start git / gitBash  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 5
  • 6. 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 /usr/bin/vim  You may also want to turn on colors:  git config --global color.ui auto  See your options:  git config -l 6
  • 7. Your repositories  We have created 6 class repositories on panther, and here are their paths.  ssh://user_name@panther.adelphi.edu/opt/git/csc271books.git  ssh://user_name@panther.adelphi.edu/opt/git/csc271tv.git  ssh://user_name@panther.adelphi.edu/opt/git/csc271store.git  ssh://user_name@panther.adelphi.edu/opt/git/csc271movies1.git  ssh://user_name@panther.adelphi.edu/opt/git/csc271games1.git  ssh://user_name@panther.adelphi.edu/opt/git/csc271movies2.git  Prior class: csc440Spring14r1  Use instructions to follow 7
  • 8. Using your repositories on panther  Get the files from your repository before starting  Make a local respository as a clone of master  git clone /opt/git/csc271books  See all the contents of the folder  ls -a to see the .git folder.  Make changes  See what changed  git diff  Stage changes  git add –all (or particular files)  git diff –cached  Still only in your repository 8
  • 9. Using your repository  Put changes back up into repository  Commit your staged changes in your repository  git commit -m "the reason for the change"  Update the respository:  git push origin  See what is on the repository  git remote  Get what is on repository  git pull  If it says to resolve manually, just vi that file and see the head which is yours 9
  • 10. 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  git add –-all (or just changes)  git commit –m “What I did”  git push 10
  • 11. Helpful gitBash commands  Show staged differences: git diff -- cached  Show status : git status  Show branches: git branch  See history: git log  Checkout a branch: git checkout branch  Fetch so you can look but maybe not take: git fetch  Pull will fetch and merge with what you have: git merge 11
  • 12. Git log commands  git log  --pretty=oneline --max-count=2 git log  --pretty=oneline --since='5 minutes ago' git log  --pretty=oneline --until='5 minutes ago' git log  --pretty=oneline --author=<your name> git log  --pretty=oneline –all 12
  • 13. Git log pretty  git log --pretty=format:"%h %ad | %s%d [%an]" --graph -- date=short  --pretty="..." defines the output format.  %h is the abbreviated hash of the commit  %d commit decorations (e.g. branch heads or tags)  %ad is the commit date  %s is the comment  %an is the name of the author  --graph tells git to display the commit tree in the form of an ASCII graph layout  --date=short keeps the date format short and nice 13
  • 14. Good aliases  alias gs='git status '  alias ga='git add '  alias gb='git branch '  alias gc='git commit'  alias gd='git diff'  alias go='git checkout '  alias gk='gitk --all&'  alias gx='gitx --all'  alias got='git '  alias get='git ' 14