SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Git & Github - A primer
Suryakumar Sudar, iQuanti
Git - Installation Instructions
For Linux :
sudo apt-get install git
For Windows:
https://git-scm.com/download/win
Version Control Systems - an Introduction
Version control is a system that records
changes to a file or set of files over time
so that you can recall specific versions
later.
It acts as a backup system as well as a
revision tool.
**What features would you want in your
ideal VCS?
Version Control System - Essential Functions
● Should support reversion of a project/file to a previous state
● Should support Branching/Merging
● Should aid Traceability
● Should be distributed, not centralized
Git - Architecture & Salient Features
● Entire history is present locally
● Fast operations with no need of a
network
● Distributed architecture
● Supports parallelism at scale, eg:
thousands of feature branches
Workflow - Three States [Modified - Staged - Committed]
● Committed means that the data is safely
stored in your local database
● Modified means that you have changed
the file but have not committed it to your
database yet.
● Staged means that you have marked a
modified file in its current version to go
into your next commit snapshot
** the current working directory is referred to
as HEAD
To create a new
repository
git init
Create a new directory and execute the
command to initialize a repository
To add files to
repository and
commit the
changes
Create a new file and add it to the
staging area:
git add --all
Commit the changes and add a log
message:
git commit -a
Git - Branching
Branches are used to develop
features in isolation without
affecting the primary branch
(master*)
git branch
<branch_name>
Creates a new branch
*By default, the primary branch is
named “master” by git.
To switch between
states*
*States can refer to either branches
or commits
Create a new branch from the current
state of the project:
git checkout -b <branch name>
To switch to an already existing branch:
git checkout <branch_name>
To switch to a different commit ID:
git checkout <commit_id>
To inspect a
repository
Lists commit history with additional
information including author, commit ID
and log message:
git log
Check the status of working directory
and the staging area:
git status
Git - Merging
Merging is done to combine the changes
made in one branch to another.
Command to merge:
“git merge <branch1>“ will merge
branch1 with the current branch
**Do you foresee any potential pitfalls?
Merge conflicts and resolution
git automatically merges files when
possible
Exceptions arise when git tries to merge
files where contents are changed in both
the branches.
These ‘merge-conflicts’ have to be
resolved manually. The code-segment to
the right describes how git presents
conflicts.
Git remotes and Github
● Remotes refer to servers which host repositories
● Companies which provide such service (Remotes): Github, Bitbucket, AWS CodeCommit
etc..
● As convention, we refer to the primary remote as ‘origin’. This is purely conventional
and there is no specific importance attached to the term ‘origin’.
Add/List remotes of
a repository
Add a remote to an existing repository:
git remote add <remote_name>
<remote_URL>
Eg: git remote add origin
https://github.com/user/repo.git
List remotes of a repository:
git remote -v
Working with
remotes
To download/clone a repository:
git clone <github_URL>
To push changes from local to remote:
git push
To pull changes from remote to local:
git pull [will merge local
branch with remote]
Additional Tips
● Commit often
● Branch whenever required
● Decide upon a workflow with your team
● Always pull before you push code to
remote
● Write meaningful commit messages
● “git stash” and “git stash pop” to
save intermediate changes
● “git reset HEAD --hard” to reset
local changes
● Never push sensitive keys/credentials
to a public repository
References and further reading
● https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
● https://in.udacity.com/course/how-to-use-git-and-github--ud775
● https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
● https://github.com/pluralsight/git-internals-pdf
Thank you

Contenu connexe

Tendances

Version control git day02
Version control   git day02Version control   git day02
Version control git day02Gourav Varma
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucketMedhat Dawoud
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03Gourav Varma
 
Git hub abduallah abu nada
Git hub   abduallah abu nadaGit hub   abduallah abu nada
Git hub abduallah abu nadaLama K Banna
 
Gitt and Git-flow
Gitt and Git-flowGitt and Git-flow
Gitt and Git-flowMd. Masud
 
An introductory guide to GIT
An introductory guide to GITAn introductory guide to GIT
An introductory guide to GITAmith jayasekara
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanJames Ford
 
Git strategies for DevOps
Git strategies for DevOpsGit strategies for DevOps
Git strategies for DevOpsAhmad Iqbal Ali
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumAbhijitNarayan2
 

Tendances (20)

Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git commands
Git commandsGit commands
Git commands
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git Training
Git TrainingGit Training
Git Training
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git hub abduallah abu nada
Git hub   abduallah abu nadaGit hub   abduallah abu nada
Git hub abduallah abu nada
 
Git overview
Git overviewGit overview
Git overview
 
Gitt and Git-flow
Gitt and Git-flowGitt and Git-flow
Gitt and Git-flow
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
An introductory guide to GIT
An introductory guide to GITAn introductory guide to GIT
An introductory guide to GIT
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
Git strategies for DevOps
Git strategies for DevOpsGit strategies for DevOps
Git strategies for DevOps
 
Git 101
Git 101Git 101
Git 101
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git basics
Git basicsGit basics
Git basics
 

Similaire à Git and Github - A primer

Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
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
 
Git slides
Git slidesGit slides
Git slidesNanyak S
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGandhi Ramu
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptxEshaan35
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016Peter Denev
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing selfChen-Tien Tsai
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 

Similaire à Git and Github - A primer (20)

Git introduction
Git introductionGit introduction
Git introduction
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
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 slides
Git slidesGit slides
Git slides
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_Guidewire
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
Git hub
Git hubGit hub
Git hub
 
github_gyan.pptx
github_gyan.pptxgithub_gyan.pptx
github_gyan.pptx
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Git basics
Git basicsGit basics
Git basics
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git
GitGit
Git
 

Dernier

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 

Dernier (20)

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 

Git and Github - A primer

  • 1. Git & Github - A primer Suryakumar Sudar, iQuanti
  • 2. Git - Installation Instructions For Linux : sudo apt-get install git For Windows: https://git-scm.com/download/win
  • 3. Version Control Systems - an Introduction Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It acts as a backup system as well as a revision tool. **What features would you want in your ideal VCS?
  • 4. Version Control System - Essential Functions ● Should support reversion of a project/file to a previous state ● Should support Branching/Merging ● Should aid Traceability ● Should be distributed, not centralized
  • 5. Git - Architecture & Salient Features ● Entire history is present locally ● Fast operations with no need of a network ● Distributed architecture ● Supports parallelism at scale, eg: thousands of feature branches
  • 6. Workflow - Three States [Modified - Staged - Committed] ● Committed means that the data is safely stored in your local database ● Modified means that you have changed the file but have not committed it to your database yet. ● Staged means that you have marked a modified file in its current version to go into your next commit snapshot ** the current working directory is referred to as HEAD
  • 7. To create a new repository git init Create a new directory and execute the command to initialize a repository
  • 8. To add files to repository and commit the changes Create a new file and add it to the staging area: git add --all Commit the changes and add a log message: git commit -a
  • 9. Git - Branching Branches are used to develop features in isolation without affecting the primary branch (master*) git branch <branch_name> Creates a new branch *By default, the primary branch is named “master” by git.
  • 10. To switch between states* *States can refer to either branches or commits Create a new branch from the current state of the project: git checkout -b <branch name> To switch to an already existing branch: git checkout <branch_name> To switch to a different commit ID: git checkout <commit_id>
  • 11. To inspect a repository Lists commit history with additional information including author, commit ID and log message: git log Check the status of working directory and the staging area: git status
  • 12. Git - Merging Merging is done to combine the changes made in one branch to another. Command to merge: “git merge <branch1>“ will merge branch1 with the current branch **Do you foresee any potential pitfalls?
  • 13. Merge conflicts and resolution git automatically merges files when possible Exceptions arise when git tries to merge files where contents are changed in both the branches. These ‘merge-conflicts’ have to be resolved manually. The code-segment to the right describes how git presents conflicts.
  • 14. Git remotes and Github ● Remotes refer to servers which host repositories ● Companies which provide such service (Remotes): Github, Bitbucket, AWS CodeCommit etc.. ● As convention, we refer to the primary remote as ‘origin’. This is purely conventional and there is no specific importance attached to the term ‘origin’.
  • 15. Add/List remotes of a repository Add a remote to an existing repository: git remote add <remote_name> <remote_URL> Eg: git remote add origin https://github.com/user/repo.git List remotes of a repository: git remote -v
  • 16. Working with remotes To download/clone a repository: git clone <github_URL> To push changes from local to remote: git push To pull changes from remote to local: git pull [will merge local branch with remote]
  • 17. Additional Tips ● Commit often ● Branch whenever required ● Decide upon a workflow with your team ● Always pull before you push code to remote ● Write meaningful commit messages ● “git stash” and “git stash pop” to save intermediate changes ● “git reset HEAD --hard” to reset local changes ● Never push sensitive keys/credentials to a public repository
  • 18. References and further reading ● https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control ● https://in.udacity.com/course/how-to-use-git-and-github--ud775 ● https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud ● https://github.com/pluralsight/git-internals-pdf