SlideShare a Scribd company logo
Introduction to Git
Siddhant Bhardwaj
What is Git ?
● Git is a version control system.
● Git helps you keep track of code changes.
● Git is used to collaborate on code.
What Does Git Do ?
● Manage projects with Repositories
● Clone a project to work on a local copy
● Control and track changes with
● Staging and Committing Branch and Merge to allow for work on
different parts and versions of a project
● Pull the latest version of the project to a local copy Push local
updates to the main project
How Does Git Work ?
Initialize Git on a folder, making it a Repository
Git now creates a hidden folder to keep track of changes in that folder
When a file is changed, added or deleted, it is considered modified
You select the modified files you want to Stage
The Staged files are Committed, which prompts Git to store a permanent
snapshot of the files
Git allows you to see the full history of every commit.
You can revert back to any previous commit. Git does not store a separate
copy of every file in every commit, but keeps track of changes made in each
commit!
Creating a Git Repo
● In order to create a git repository, we need to use the command - git
init in the folder where we desire to create a git repo.
Git Staging
Now our git repository has been created, but it does not have any files
yet.
When we create a new file in the repository, ls will list the files in the
directory.
Then we check the Git status and see if it is a part of our repo.
We can check by using the command git status.
Git Staging
Now Git is aware of the file, but has not added it to our repository!
Files in your Git repository folder can be in one of 2 states:
● Tracked - files that Git knows about and are added to the repository
.
● Untracked - files that are in your working directory, but not added
to the repository
Git Commit
Since we have finished our work, we are ready move from stage to
commit for our repo.
Adding commits keep track of our progress and changes as we work.
When we commit, we should always include a message.
git commit -m "First release of Hello World!"
The commit command performs a commit, and the -m "message" adds a
message.
Git Help
If you are having trouble remembering commands or options for
commands, you can use Git help.
There are a couple of different ways you can use the help command
in command line:
git command -help - See all the available options for the specific
command
git help --all - See all possible commands
Git Branch
In Git, a branch is a new/separate version of the main repository.
Branches allow you to work on different parts of a project without impacting
the main branch.
When the work is complete, a branch can be merged with the main project.
git branch new-branch is used to create a new branch.
git checkout new-branch can be used to checkout a branch.
git checkout -b new-branch can be used to create and checkout a new branch.
Git Merge Branch
First, we need to change to the main branch:
git checkout main.
Now we merge the current branch (main) with new-branch:
git merge new-branch.
Gitignore
When sharing your code with others, there are often files or parts of your
project, you do not want to share - personal files, log files etc.
Git can specify which files or parts of your project should be ignored by
Git using a .gitignore file.
Git will not track files and folders specified in .gitignore. However, the
.gitignore file itself IS tracked by Git.
Git Revert
revert is the command we use when we want to take a previous commit
and add it as a new commit, keeping the log intact.
git revert <commit hash>
In order to obtain the commit hash of the commit that we want to revert
to, we can use the following command - git log --oneline
Git Reset
reset is the command we use when we want to move the repository back
to a previous commit, discarding any changes made after that commit.
It brings the repository back to an earlier state in the commits without
making a new commit.
Similar to git revert, we get the hashcode of the git commit we want to
reset to -
git reset <git hash>

More Related Content

Similar to Introduction to Git.pptx

16 Git
16 Git16 Git
Gn unify git
Gn unify gitGn unify git
Gn unify git
Priyanka Nag
 
Formation git
Formation gitFormation git
Formation git
Ghariani Tewfik
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
Mithilesh Singh
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
Gabriele Baldassarre
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
Git&GitHub.pptx
Git&GitHub.pptxGit&GitHub.pptx
Git&GitHub.pptx
KondiVenkatesh1
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git
John Tighe
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
DivineOmega
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
Md. Main Uddin Rony
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
Mohamed Abdeen
 
Day 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptxDay 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptx
Google Developer Students Clubs - CTU
 
Git github
Git githubGit github
Git github
Anurag Deb
 
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 & Github
Git & GithubGit & Github
Git & Github
Aman Lalpuria
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri
 

Similar to Introduction to Git.pptx (20)

16 Git
16 Git16 Git
16 Git
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
 
Formation git
Formation gitFormation git
Formation git
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Git for the absolute beginners
Git for the absolute beginnersGit for the absolute beginners
Git for the absolute beginners
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Git&GitHub.pptx
Git&GitHub.pptxGit&GitHub.pptx
Git&GitHub.pptx
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
 
Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git Git 101 - An introduction to Version Control using Git
Git 101 - An introduction to Version Control using Git
 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
 
Git introduction
Git introductionGit introduction
Git introduction
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
Day 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptxDay 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptx
 
Git github
Git githubGit github
Git github
 
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 & Github
Git & GithubGit & Github
Git & Github
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 

Recently uploaded

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
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
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 

Recently uploaded (20)

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
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
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 

Introduction to Git.pptx

  • 2. What is Git ? ● Git is a version control system. ● Git helps you keep track of code changes. ● Git is used to collaborate on code.
  • 3. What Does Git Do ? ● Manage projects with Repositories ● Clone a project to work on a local copy ● Control and track changes with ● Staging and Committing Branch and Merge to allow for work on different parts and versions of a project ● Pull the latest version of the project to a local copy Push local updates to the main project
  • 4. How Does Git Work ? Initialize Git on a folder, making it a Repository Git now creates a hidden folder to keep track of changes in that folder When a file is changed, added or deleted, it is considered modified You select the modified files you want to Stage The Staged files are Committed, which prompts Git to store a permanent snapshot of the files Git allows you to see the full history of every commit. You can revert back to any previous commit. Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!
  • 5. Creating a Git Repo ● In order to create a git repository, we need to use the command - git init in the folder where we desire to create a git repo.
  • 6. Git Staging Now our git repository has been created, but it does not have any files yet. When we create a new file in the repository, ls will list the files in the directory. Then we check the Git status and see if it is a part of our repo. We can check by using the command git status.
  • 7. Git Staging Now Git is aware of the file, but has not added it to our repository! Files in your Git repository folder can be in one of 2 states: ● Tracked - files that Git knows about and are added to the repository . ● Untracked - files that are in your working directory, but not added to the repository
  • 8. Git Commit Since we have finished our work, we are ready move from stage to commit for our repo. Adding commits keep track of our progress and changes as we work. When we commit, we should always include a message. git commit -m "First release of Hello World!" The commit command performs a commit, and the -m "message" adds a message.
  • 9. Git Help If you are having trouble remembering commands or options for commands, you can use Git help. There are a couple of different ways you can use the help command in command line: git command -help - See all the available options for the specific command git help --all - See all possible commands
  • 10. Git Branch In Git, a branch is a new/separate version of the main repository. Branches allow you to work on different parts of a project without impacting the main branch. When the work is complete, a branch can be merged with the main project. git branch new-branch is used to create a new branch. git checkout new-branch can be used to checkout a branch. git checkout -b new-branch can be used to create and checkout a new branch.
  • 11. Git Merge Branch First, we need to change to the main branch: git checkout main. Now we merge the current branch (main) with new-branch: git merge new-branch.
  • 12. Gitignore When sharing your code with others, there are often files or parts of your project, you do not want to share - personal files, log files etc. Git can specify which files or parts of your project should be ignored by Git using a .gitignore file. Git will not track files and folders specified in .gitignore. However, the .gitignore file itself IS tracked by Git.
  • 13. Git Revert revert is the command we use when we want to take a previous commit and add it as a new commit, keeping the log intact. git revert <commit hash> In order to obtain the commit hash of the commit that we want to revert to, we can use the following command - git log --oneline
  • 14. Git Reset reset is the command we use when we want to move the repository back to a previous commit, discarding any changes made after that commit. It brings the repository back to an earlier state in the commits without making a new commit. Similar to git revert, we get the hashcode of the git commit we want to reset to - git reset <git hash>