SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
GIT BASICS
Presented by
T. Pravallika
DV Engineer
Agenda
 What is Git?
 What is Repository?
 Version Control System.
 Centralised Version Control System.
 Distributed Version Control system.
 Git Workflow.
 Git Commands.
 Features and Benefits of Git.
What is Git??
 Git was created by Linus Torvalds in April 2005 to develop Linux Kernel.
 Replacement for bitkeeper to manage Linux Kernel changes.
 A command line version control program.
 Uses checksums to ensure Data Integrity.
 Distributed Version Control.
 Cross Platform(Including Windows).
 Free & open-source control system .
What is Repository?
 Repo = Repository
 Usually needs to organize a single project.
 It contains folders, files, images, videos, spreadsheets and datasets --- anything your project needs.
Two-tree Architecture
Repository
Working
Three-tree Architecture
Repository
Working
Staging Index
Checkout Commit
Checkout
Commit
add
Version Control System
 A way to manage files and directories
 Track changes over time
 Recall previous versions
 Source control is a subset of VCS
Version 1
Repository
File 1
File 2
File 3
Version 2
File 1
File 2
File 3
File 2.1
Snapshot
Snapshot
Fig : Version control system
Centralised Version Control System
 Uses a central server to store files.
 Every operation is performed directly on the repository.
 All the versions of the file are stored on the central VCS server.
 Incase the central server crashes, the entire data of the project will be lost. Hence Distributed VCS was Introduced.
Centralised
VCS server
System A file
System B file
System A file System B file
Fig : Centralised Version Control System
Distribution Version Control
 No need to connect central server.
 It can work without Internet connection.
 Developers can Work Independently and merge their work later.
 Every copy of a Git repository can serve either as a client or a server.
 It can track changes, not Versions.
Repo Repo
Repo
client client
client
Fig : Distributed
client
client
client client
Repo
Fig : Traditional
Git Workflow
Working Directory
Modify working Copy
Review Changes
Commit changes
Review Changes
edit, add, move files
Status and diff operation
Commit and push operation
ammend and push operation
Clone operation
Update Operation
Push operation
Push operation
Git Workflow is divided into three stages
Working Directory
Staging Area
(Index)
Git Directory
(Repository)
Checkout the changes
Stage files
Commit
Git Commands
1. git config - sets the author name and email address respectively to be used with your commits
Usage : git config –global user.name “[name]”
Usage : git config –global user.email “[email address]”
2. git init : used to start a new repository
Usage : git init [git repository]
3. git clone – used to obtain a repository from an existing URL
Usage : git clone [url]
4. git add : adds a file to a staging area
Usage : git add [file]
Usage : git add *
5. git status : this command lists all the files that you have to be committed
Usage : git status
6. git commit
Usage : git commit –m “[type in the commit message]”
This command records or snapshots the file permanently in the version history.
Usage : git commit –a
This command commits anyfiles you hav added with the git add command and also commits any files u have changed since
then.
7. git diff
Usage : git diff
This command shows the differences which are not yet staged.
Usage : git diff –staged
This command shows the differences between the files in the staging area and the latest version present.
8. git reset
Usage : git reset [file]
This command unstages the file, but it preserves the file contents.
Usage : git reset [commit]
This command undo’s all the commits after the specified commit and preserves the changes locally.
Usage : git reset –hard[commit]
This command discards all history and goes back to the specified commit.
9. git rm – deletes the file from your working directory and stages the deletion.
Usage : git rm [file]
10. git log
Usage : git log
This command used to list the version history for the current branch.
Usage : git log –follow[file]
This command lists version history for a file, including renaming files also.
11. git show - This command shows the meta data and content changes of the specified commit.
Usage : git show [commit]
12. git tag – used to give tags to the specified amount
Usage : git tag [commit ID]
13. git merge : merges the specified branch ‘s history into the current branch.
Usage : git merge [branch name]
14. git branch
Usage : git branch
This commands lists all the local branches in the current repository
Usage : git branch [branch name]
This command creates a new branch.
Usage : git branch –d [branch name]
This command deletes the feature branch.
15. git checkout
Usage : git checkout [branch name]
This command is used to switch from one branch to another.
Usage : git checkout –b [branch name]
This command creates a new branch and also switches to it.
16. git remote
Usage : git remote add [variable name] [remote server link]
This command is used to connect your local repository to the remote server.
17. git push
Usage : git push [variable name] [master]
This command sends the committed changes o master branch to your remote repository.
Usage : git push [variable name] [branch]
This commands sends the branch commits to your remote repository.
Usage : git push –all [variable name]
This command pushes all branches to your remote repository.
18. git pull – fetches and merges changes to your remote server to the working directory.
Usage : git pull [repository link]
19. git stash
Usage : git stash save
This command temporarily stores all the modified tracked files.
Usage : git stash list
This command lists all stashed changesets.
Usage : git stash drop
This command discards the most recently stashed changeset.
Github remote
server
Forked branch Master
fork
Pull request
Origin/master “branch”
Working Directory
Repo
Stage
add
Commit
merge
checkout
merge
Local
Origin/master
references remote
server branch and
tries to say in sync
Someone else
master
Pull/fetch
push
Repository
Staging Area
Working Directory
add
commit
Repository
Staging Area
Working Directory
add
commit
Repository
Staging Area
Working Directory
add
commit
Central Server
Repository
pull push
pull
push
pull
push
Your local repository Jon’s local repository
Matt’s local repository
Features of Git
 Open source
 Scalable
 Distributed
 Security
 Speed
 Supports non-linear development
 Branching and Merging
 Data Assurance
 Staging Area
 Maintains the clean History
Benefits of Git
 Saves time
 Offline Working
 Undo Mistakes
 Track Changes
 Free and open Source
 Implicit backup
 No need of powerful Hardware
 Easier Branching
THANK YOU

Mais conteúdo relacionado

Mais procurados

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Version control system
Version control systemVersion control system
Version control systemAndrew Liu
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewRueful Robin
 
はじめてのGit forデザイナー&コーダー
はじめてのGit forデザイナー&コーダーはじめてのGit forデザイナー&コーダー
はじめてのGit forデザイナー&コーダーSaeko Yamamoto
 
Git - Sistema Descentralizado de Controle de Versões
Git - Sistema Descentralizado de Controle de VersõesGit - Sistema Descentralizado de Controle de Versões
Git - Sistema Descentralizado de Controle de VersõesLeandro Cavalcante
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git 입문자를 위한 가이드
Git 입문자를 위한 가이드Git 입문자를 위한 가이드
Git 입문자를 위한 가이드chandler0201
 

Mais procurados (20)

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Version control system
Version control systemVersion control system
Version control system
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git
GitGit
Git
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
git and github
git and githubgit and github
git and github
 
Aprendendo Git
Aprendendo GitAprendendo Git
Aprendendo Git
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
はじめてのGit forデザイナー&コーダー
はじめてのGit forデザイナー&コーダーはじめてのGit forデザイナー&コーダー
はじめてのGit forデザイナー&コーダー
 
Git - Sistema Descentralizado de Controle de Versões
Git - Sistema Descentralizado de Controle de VersõesGit - Sistema Descentralizado de Controle de Versões
Git - Sistema Descentralizado de Controle de Versões
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git basic
Git basicGit basic
Git basic
 
Github basics
Github basicsGithub basics
Github basics
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git 입문자를 위한 가이드
Git 입문자를 위한 가이드Git 입문자를 위한 가이드
Git 입문자를 위한 가이드
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git commands
Git commandsGit commands
Git commands
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git e GitHub - Conceitos Básicos
Git e GitHub - Conceitos BásicosGit e GitHub - Conceitos Básicos
Git e GitHub - Conceitos Básicos
 

Semelhante a Git basics for beginners

Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitRasan Samarasinghe
 
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 cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheetLam Hoang
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
GITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubGITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubalidor4702
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 

Semelhante a Git basics for beginners (20)

Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
 
Git introduction
Git introductionGit introduction
Git introduction
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git&GitHub.pptx
Git&GitHub.pptxGit&GitHub.pptx
Git&GitHub.pptx
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git learning
Git learningGit learning
Git learning
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
GITHappens, powerpoint about git and github
GITHappens, powerpoint about git and githubGITHappens, powerpoint about git and github
GITHappens, powerpoint about git and github
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Git github
Git githubGit github
Git github
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 

Último

TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
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
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 

Último (20)

TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
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
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 

Git basics for beginners

  • 1. GIT BASICS Presented by T. Pravallika DV Engineer
  • 2. Agenda  What is Git?  What is Repository?  Version Control System.  Centralised Version Control System.  Distributed Version Control system.  Git Workflow.  Git Commands.  Features and Benefits of Git.
  • 3. What is Git??  Git was created by Linus Torvalds in April 2005 to develop Linux Kernel.  Replacement for bitkeeper to manage Linux Kernel changes.  A command line version control program.  Uses checksums to ensure Data Integrity.  Distributed Version Control.  Cross Platform(Including Windows).  Free & open-source control system . What is Repository?  Repo = Repository  Usually needs to organize a single project.  It contains folders, files, images, videos, spreadsheets and datasets --- anything your project needs.
  • 5. Version Control System  A way to manage files and directories  Track changes over time  Recall previous versions  Source control is a subset of VCS Version 1 Repository File 1 File 2 File 3 Version 2 File 1 File 2 File 3 File 2.1 Snapshot Snapshot Fig : Version control system
  • 6. Centralised Version Control System  Uses a central server to store files.  Every operation is performed directly on the repository.  All the versions of the file are stored on the central VCS server.  Incase the central server crashes, the entire data of the project will be lost. Hence Distributed VCS was Introduced. Centralised VCS server System A file System B file System A file System B file Fig : Centralised Version Control System
  • 7. Distribution Version Control  No need to connect central server.  It can work without Internet connection.  Developers can Work Independently and merge their work later.  Every copy of a Git repository can serve either as a client or a server.  It can track changes, not Versions. Repo Repo Repo client client client Fig : Distributed client client client client Repo Fig : Traditional
  • 8. Git Workflow Working Directory Modify working Copy Review Changes Commit changes Review Changes edit, add, move files Status and diff operation Commit and push operation ammend and push operation Clone operation Update Operation Push operation Push operation
  • 9. Git Workflow is divided into three stages Working Directory Staging Area (Index) Git Directory (Repository) Checkout the changes Stage files Commit
  • 10. Git Commands 1. git config - sets the author name and email address respectively to be used with your commits Usage : git config –global user.name “[name]” Usage : git config –global user.email “[email address]” 2. git init : used to start a new repository Usage : git init [git repository] 3. git clone – used to obtain a repository from an existing URL Usage : git clone [url] 4. git add : adds a file to a staging area Usage : git add [file] Usage : git add * 5. git status : this command lists all the files that you have to be committed Usage : git status
  • 11. 6. git commit Usage : git commit –m “[type in the commit message]” This command records or snapshots the file permanently in the version history. Usage : git commit –a This command commits anyfiles you hav added with the git add command and also commits any files u have changed since then. 7. git diff Usage : git diff This command shows the differences which are not yet staged. Usage : git diff –staged This command shows the differences between the files in the staging area and the latest version present. 8. git reset Usage : git reset [file] This command unstages the file, but it preserves the file contents. Usage : git reset [commit] This command undo’s all the commits after the specified commit and preserves the changes locally. Usage : git reset –hard[commit] This command discards all history and goes back to the specified commit.
  • 12. 9. git rm – deletes the file from your working directory and stages the deletion. Usage : git rm [file] 10. git log Usage : git log This command used to list the version history for the current branch. Usage : git log –follow[file] This command lists version history for a file, including renaming files also. 11. git show - This command shows the meta data and content changes of the specified commit. Usage : git show [commit] 12. git tag – used to give tags to the specified amount Usage : git tag [commit ID] 13. git merge : merges the specified branch ‘s history into the current branch. Usage : git merge [branch name]
  • 13. 14. git branch Usage : git branch This commands lists all the local branches in the current repository Usage : git branch [branch name] This command creates a new branch. Usage : git branch –d [branch name] This command deletes the feature branch. 15. git checkout Usage : git checkout [branch name] This command is used to switch from one branch to another. Usage : git checkout –b [branch name] This command creates a new branch and also switches to it. 16. git remote Usage : git remote add [variable name] [remote server link] This command is used to connect your local repository to the remote server.
  • 14. 17. git push Usage : git push [variable name] [master] This command sends the committed changes o master branch to your remote repository. Usage : git push [variable name] [branch] This commands sends the branch commits to your remote repository. Usage : git push –all [variable name] This command pushes all branches to your remote repository. 18. git pull – fetches and merges changes to your remote server to the working directory. Usage : git pull [repository link] 19. git stash Usage : git stash save This command temporarily stores all the modified tracked files. Usage : git stash list This command lists all stashed changesets. Usage : git stash drop This command discards the most recently stashed changeset.
  • 15. Github remote server Forked branch Master fork Pull request Origin/master “branch” Working Directory Repo Stage add Commit merge checkout merge Local Origin/master references remote server branch and tries to say in sync Someone else master Pull/fetch push
  • 16. Repository Staging Area Working Directory add commit Repository Staging Area Working Directory add commit Repository Staging Area Working Directory add commit Central Server Repository pull push pull push pull push Your local repository Jon’s local repository Matt’s local repository
  • 17. Features of Git  Open source  Scalable  Distributed  Security  Speed  Supports non-linear development  Branching and Merging  Data Assurance  Staging Area  Maintains the clean History Benefits of Git  Saves time  Offline Working  Undo Mistakes  Track Changes  Free and open Source  Implicit backup  No need of powerful Hardware  Easier Branching