SlideShare a Scribd company logo
1 of 14
WHAT THE GIT?!
GIT BASICS
NO GIT!
(WHY USE VERSION CONTROL SOFTWARE)
• Version control software(such as GIT, Mercurial, Perforce, SVN etc.) allows to
have “versions” of a project, which show the changes that were made to the code
over time, and allowing to backtrack if necessary and undo those changes.
• Ease of collaborating with other developers.
GIT THE HELL OUT
(WHY GIT IS *BEST* VERSION CONTROL SOFTWARE AVAILABLE)
• Performance:
• Git tracks state, history and integrity of the source tree.
• Git works with the whole repo instead of individual files.
• Git is distributed which allows offline work.
• Ok, No more Jokes. Lets Git started(ok maybe one more)
CHECKOUT A REPOSITORY
• create a working copy of a local repository by running the command
git clone /path/to/repository
• when using a remote server, your command will be
git clone username@host:/path/to/repository
WORKFLOW
• your local repository consists of three "trees" maintained by git. the first one is
your Working Directory which holds the actual files. the second one is the Index
which acts as a staging area and finally the HEAD which points to the last
commit you've made
Working git add Index/stage git commit HEAD
ADD & COMMIT
• You can propose changes (add it to the Index) using
git add <filename>
git add *
• This is the first step in the basic git workflow. To actually commit these changes
use
git commit -m "Commit message”
• Now the file is committed to the HEAD, but not in your remote repository yet.
PUSHING CHANGES
• Your changes are now in the HEAD of your local working copy. To send those changes to your
remote repository, execute
git push origin master
• Change master to whatever branch you want to push your changes to.
• If you have not cloned an existing repository and want to connect your repository to a remote
server, you need to add it with
git remote add origin <server>
• Now you are able to push your changes to the selected remote server
BRANCHING
• Branches are used to develop features isolated from each other. The master branch is the "default"
branch when you create a repository. Use other branches for development and merge them back to
the master branch upon completion.
• create a new branch named "feature_x" and switch to it using
git checkout -b feature_x
• switch back to master
git checkout master
• and delete the branch again
git branch -d feature_x
• a branch is not available to others unless you push the branch to your remote repository
git push origin <branch>.
UPDATE & MERGE
• to update your local repository to the newest commit, execute
git pull
• in your working directory to fetch and merge remote changes.
to merge another branch into your active branch (e.g. master), use
git merge <branch>
• in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and
results in conflicts. You are responsible to merge those conflicts manually by editing the files
shown by git. After changing, you need to mark them as merged with
git add <filename>
• before merging changes, you can also preview them by using
git diff <source_branch> <target_branch>
LOG
• in its simplest form, you can study repository history using.. git log
You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain
author:
git log --author=bob
• To see a very compressed log where each commit is one line:
git log --pretty=oneline
• Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
git log --graph --oneline --decorate –all
• See only which files have changed:
git log --name-status
• These are just a few of the possible parameters you can use. For more, see 'git log –help’
REPLACE LOCAL CHANGES
• In case you did something wrong, which for sure never happens ;), you can
replace local changes using the command
git checkout -- <filename>
• this replaces the changes in your working tree with the last content in HEAD.
Changes already added to the index, as well as new files, will be kept.
• If you instead want to drop all your local changes and commits, fetch the latest
history from the server and point your local master branch at it like this
git fetch origin
git reset --hard origin/master
USEFUL HINTS
• built-in git GUI
gitk
• use colorful git output
git config color.ui true
• show log on just one line per commit
git config format.pretty oneline
• use interactive adding
git add -i /git add –p
• Status of the local tree
git status
• References:
• http://rogerdudler.github.io/git-guide/
• http://www.makeuseof.com/tag/git-version-control-youre-developer/
• Interesting links:
• http://sixrevisions.com/git/why-you-should-use-git/
• https://stevebennett.me/2012/02/24/10-things-i-hate-about-git/
• https://www.git-tower.com/blog/8-reasons-for-switching-to-git
• https://www.youtube.com/watch?v=4XpnKHJAok8

More Related Content

What's hot

Git workflows
Git workflowsGit workflows
Git workflowsXpand IT
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Omar Fathy
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHubDSCVSSUT
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version ControlSourabh Sahu
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionAnwarul Islam
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow IntroductionDavid Paluy
 

What's hot (20)

Git workflows
Git workflowsGit workflows
Git workflows
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Github basics
Github basicsGithub basics
Github basics
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git basics
Git basicsGit basics
Git basics
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Introducing GitLab
Introducing GitLabIntroducing GitLab
Introducing GitLab
 
git and github
git and githubgit and github
git and github
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git flow Introduction
Git flow IntroductionGit flow Introduction
Git flow Introduction
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 

Similar to Git 101 (20)

Git and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slideGit and Github workshop ppt slide by slide
Git and Github workshop ppt slide by slide
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Git for developers
Git for developersGit for developers
Git for developers
 
Git tips and tricks
Git   tips and tricksGit   tips and tricks
Git tips and tricks
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
18 Git #burningkeyboards
18 Git #burningkeyboards18 Git #burningkeyboards
18 Git #burningkeyboards
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git
Git Git
Git
 
Git hub
Git hubGit hub
Git hub
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git basic commands
Git basic commandsGit basic commands
Git basic commands
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Gitlikeapro 2019
Gitlikeapro 2019Gitlikeapro 2019
Gitlikeapro 2019
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Git 101

  • 2. NO GIT! (WHY USE VERSION CONTROL SOFTWARE) • Version control software(such as GIT, Mercurial, Perforce, SVN etc.) allows to have “versions” of a project, which show the changes that were made to the code over time, and allowing to backtrack if necessary and undo those changes. • Ease of collaborating with other developers.
  • 3. GIT THE HELL OUT (WHY GIT IS *BEST* VERSION CONTROL SOFTWARE AVAILABLE) • Performance: • Git tracks state, history and integrity of the source tree. • Git works with the whole repo instead of individual files. • Git is distributed which allows offline work.
  • 4. • Ok, No more Jokes. Lets Git started(ok maybe one more)
  • 5. CHECKOUT A REPOSITORY • create a working copy of a local repository by running the command git clone /path/to/repository • when using a remote server, your command will be git clone username@host:/path/to/repository
  • 6. WORKFLOW • your local repository consists of three "trees" maintained by git. the first one is your Working Directory which holds the actual files. the second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you've made Working git add Index/stage git commit HEAD
  • 7. ADD & COMMIT • You can propose changes (add it to the Index) using git add <filename> git add * • This is the first step in the basic git workflow. To actually commit these changes use git commit -m "Commit message” • Now the file is committed to the HEAD, but not in your remote repository yet.
  • 8. PUSHING CHANGES • Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute git push origin master • Change master to whatever branch you want to push your changes to. • If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with git remote add origin <server> • Now you are able to push your changes to the selected remote server
  • 9. BRANCHING • Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion. • create a new branch named "feature_x" and switch to it using git checkout -b feature_x • switch back to master git checkout master • and delete the branch again git branch -d feature_x • a branch is not available to others unless you push the branch to your remote repository git push origin <branch>.
  • 10. UPDATE & MERGE • to update your local repository to the newest commit, execute git pull • in your working directory to fetch and merge remote changes. to merge another branch into your active branch (e.g. master), use git merge <branch> • in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with git add <filename> • before merging changes, you can also preview them by using git diff <source_branch> <target_branch>
  • 11. LOG • in its simplest form, you can study repository history using.. git log You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author: git log --author=bob • To see a very compressed log where each commit is one line: git log --pretty=oneline • Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches: git log --graph --oneline --decorate –all • See only which files have changed: git log --name-status • These are just a few of the possible parameters you can use. For more, see 'git log –help’
  • 12. REPLACE LOCAL CHANGES • In case you did something wrong, which for sure never happens ;), you can replace local changes using the command git checkout -- <filename> • this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept. • If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this git fetch origin git reset --hard origin/master
  • 13. USEFUL HINTS • built-in git GUI gitk • use colorful git output git config color.ui true • show log on just one line per commit git config format.pretty oneline • use interactive adding git add -i /git add –p • Status of the local tree git status
  • 14. • References: • http://rogerdudler.github.io/git-guide/ • http://www.makeuseof.com/tag/git-version-control-youre-developer/ • Interesting links: • http://sixrevisions.com/git/why-you-should-use-git/ • https://stevebennett.me/2012/02/24/10-things-i-hate-about-git/ • https://www.git-tower.com/blog/8-reasons-for-switching-to-git • https://www.youtube.com/watch?v=4XpnKHJAok8