SlideShare ist ein Scribd-Unternehmen logo
1 von 68
Downloaden Sie, um offline zu lesen
git and github
darren oakley
disclaimer
• i use git daily in my work and manage to
  not have many problems
• i’ve been asked to share the basics i know
  with others
• i am not a git expert - i may (most
  probably) not be able to answer all of your
  questions
what we’ll cover

• brief discussion on version control
    - ‘traditional’ v’s distributed
• git - the basics
• github - the basics
what we won’t cover

• advanced git
 • rebase
 • sub-modules
• git-svn
version control
version control

• what most people are (probably) used to:
 • concurrent version system (cvs)
 • subversion (svn)
version control

• cvs and svn
 • central source control server
 • users check code into server
 • requires connection to the server to
    perform commits, updates etc.
distributed version
       control
• the new hotness...
 • git
 • mercurial (hg)
 • bazaar (bzr)
what’s the difference?
• not a lot really...
 • you store a complete copy of a
    repository within your working copy
   • this means you can work offline
 • there is no default ‘central’ server - if you
    want one, you (and your team) just
    nominate where it is (i.e. a github)
git
getting started

• move to a directory with code you’d like to
  manage with git:
 git init

• you’ve now created your first git
  repository!
normal workflow
local operations
working                  staging              git directory
directory                 area                (repsoitory)



                   checkout the project



            stage files



                                     commit
staging files
  git add [filenames]



• add all changed files to the staging area:
  git add .



• these changes are NOT committed yet
the git staging area

• git has a concept of a ‘staging area’
 • you first stage all of the changes that you
    are happy with
  • then you commit them
isn’t this more work?

• in short - yes
 • but it allows you to craft the exact
    commit you want - you eventually get to
    love this feature
• you can get around it if you like...
committing

git commit -m “commit message”


git commit -a -m “commit message”
branching / merging
branching

git branch
git branch [new branch name]
git checkout [new branch name]
merging

git checkout [target branch]
git merge [other branch]
git merge --squash [other branch]
rewriting history

  git rebase



• will leave that as an exercise for you to
  investigate...
remote operations
remote repositories


git push [repository] [repository branch]



git pull [repository] [repository branch]
remote operations
                                                                   user
                               repository
                                (github)

user one                                                       user



                                                      user
           repository
            (internal)


                         example - group using open source code internally with
                         modifications specific to them can easily push/pull from
user two
                         the project ‘master’
some rules i tend
to follow...
• NEVER pull when you have
  uncommitted changes - commit your
  work first

• if working on a feature, use a local
  branch, then this leaves the master
  open for other fixes

• NEVER rebase or amend commits
  that you have pushed
If you want it to work
     like cvs / svn
• simply...
 • ‘pull’ at the start of the day and at regular
    intervals (as often as you’d checkout your
    code in cvs/svn)
  • ‘push’ after every commit
github
github

• http://github.com
• popular git repository hosting site
• home to many open source projects:
 • ruby on rails, jquery to name two...
a quick hands-on
with github
the plan...

• get yourselves into pairs
• person 1:
 • create a repository
 • check in some code
 • add person 2 to project
the plan...
• person 2:
 • pull code from person 1’s repository
 • make some changes and push back to
    repository
• person 1:
 • pull these changes
the plan...

• somebody:
 • tag a release of the code
 • push this tag to github
 • stare in awe at the auto-generated tarball
if we have time...

• person 1:
 • create a local branch of the code
 • push this branch to github
• person 2:
 • pull and work with this remote branch
if we have more time


• simulate a conflict and resolve it
let’s get going...
person 1
person 2
git clone [paste ‘your clone url’]

edit something

add and commit
git push origin master
person 1
git pull origin master

see if you have the changes from your
partner
somebody
git tag rel_1.0

git push --tags
do we have time?
person 1
git branch new_feature_foo

git checkout new_feature_foo

edit something, add and commit
git push origin new_feature_foo
person 2
git remote show origin


git fetch origin new_feature_foo:new_feature_foo




git fetch [repo] [remote_branch]:[local_branch]
edit something, add and commit
git push origin new_feature_foo

cat .git/config
 - info on repository setup
simulating a conflict
person 1
without doing a git pull!

edit the file that person 2 just edited

save, add and commit changes
git push origin new_feature_foo

O_o ooops...
git pull origin new_feature_foo

(git will inform you of a conflict)

edit the file - resolve the conflict

git add, commit, push

conflict resolved! ^_^
further reading

• http://git-scm.com/documentation
• http://learn.github.com/
• http://help.github.com/
• http://www.gitready.com/
further reading
git config
some setup i find useful...
git config --global color.diff auto


git config --global color.status auto


git config --global color.branch auto


git config --global color.interactive auto
git config --global alias.st status


git config --global alias.ci commit


git config --global alias.co checkout


git config --global alias.br branch
git config --global core.excludesfile ~/.gitignore


echo "*~" >~/.gitignore


echo ".DS_Store" >>~/.gitignore

Weitere ähnliche Inhalte

Was ist angesagt?

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagramsDilum Navanjana
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Introduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsIntroduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsCarl Brown
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to gitEmanuele Olivetti
 

Was ist angesagt? (20)

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git basics
Git basicsGit basics
Git basics
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git
GitGit
Git
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Introduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsIntroduction to Git Commands and Concepts
Introduction to Git Commands and Concepts
 
Github basics
Github basicsGithub basics
Github basics
 
Git basic
Git basicGit basic
Git basic
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
 
Source control
Source controlSource control
Source control
 

Andere mochten auch

Outlining some ideas... - I-DCC Kick Off Metting
Outlining some ideas... - I-DCC Kick Off MettingOutlining some ideas... - I-DCC Kick Off Metting
Outlining some ideas... - I-DCC Kick Off MettingDarren Oakley
 
Control de versiones con Git y Github
Control de versiones con Git y GithubControl de versiones con Git y Github
Control de versiones con Git y Githubguest638090
 
Mini-tutorial de git
Mini-tutorial de gitMini-tutorial de git
Mini-tutorial de gitAntonio Ognio
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHubJames Gray
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 
An Introduction to Faye
An Introduction to FayeAn Introduction to Faye
An Introduction to FayeDarren Oakley
 

Andere mochten auch (8)

Outlining some ideas... - I-DCC Kick Off Metting
Outlining some ideas... - I-DCC Kick Off MettingOutlining some ideas... - I-DCC Kick Off Metting
Outlining some ideas... - I-DCC Kick Off Metting
 
Control de versiones con Git y Github
Control de versiones con Git y GithubControl de versiones con Git y Github
Control de versiones con Git y Github
 
Mini-tutorial de git
Mini-tutorial de gitMini-tutorial de git
Mini-tutorial de git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
An Introduction to Faye
An Introduction to FayeAn Introduction to Faye
An Introduction to Faye
 

Ähnlich wie Git and GitHub Basics

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 GitRobert Lee-Cann
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
11 git version control
11 git version control11 git version control
11 git version controlWasim Alatrash
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIsTim Osborn
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubKim Moir
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Ahmed El-Arabawy
 
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 slideRaghavendraVattikuti1
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptxtnscharishma
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthroughBimal Jain
 
Collaborative development with git
Collaborative development with gitCollaborative development with git
Collaborative development with gitJoseluis Laso
 

Ähnlich wie Git and GitHub Basics (20)

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
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
11 git version control
11 git version control11 git version control
11 git version control
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
Embedded Systems: Lecture 10: Introduction to Git & GitHub (Part 1)
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
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
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
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 walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Demo
DemoDemo
Demo
 
Collaborative development with git
Collaborative development with gitCollaborative development with git
Collaborative development with git
 

Kürzlich hochgeladen

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Kürzlich hochgeladen (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Git and GitHub Basics

  • 2. disclaimer • i use git daily in my work and manage to not have many problems • i’ve been asked to share the basics i know with others • i am not a git expert - i may (most probably) not be able to answer all of your questions
  • 3. what we’ll cover • brief discussion on version control - ‘traditional’ v’s distributed • git - the basics • github - the basics
  • 4. what we won’t cover • advanced git • rebase • sub-modules • git-svn
  • 6. version control • what most people are (probably) used to: • concurrent version system (cvs) • subversion (svn)
  • 7. version control • cvs and svn • central source control server • users check code into server • requires connection to the server to perform commits, updates etc.
  • 8. distributed version control • the new hotness... • git • mercurial (hg) • bazaar (bzr)
  • 9. what’s the difference? • not a lot really... • you store a complete copy of a repository within your working copy • this means you can work offline • there is no default ‘central’ server - if you want one, you (and your team) just nominate where it is (i.e. a github)
  • 10. git
  • 11. getting started • move to a directory with code you’d like to manage with git: git init • you’ve now created your first git repository!
  • 13. local operations working staging git directory directory area (repsoitory) checkout the project stage files commit
  • 14. staging files git add [filenames] • add all changed files to the staging area: git add . • these changes are NOT committed yet
  • 15. the git staging area • git has a concept of a ‘staging area’ • you first stage all of the changes that you are happy with • then you commit them
  • 16. isn’t this more work? • in short - yes • but it allows you to craft the exact commit you want - you eventually get to love this feature • you can get around it if you like...
  • 17. committing git commit -m “commit message” git commit -a -m “commit message”
  • 19. branching git branch git branch [new branch name] git checkout [new branch name]
  • 20. merging git checkout [target branch] git merge [other branch] git merge --squash [other branch]
  • 21. rewriting history git rebase • will leave that as an exercise for you to investigate...
  • 23. remote repositories git push [repository] [repository branch] git pull [repository] [repository branch]
  • 24. remote operations user repository (github) user one user user repository (internal) example - group using open source code internally with modifications specific to them can easily push/pull from user two the project ‘master’
  • 25. some rules i tend to follow...
  • 26. • NEVER pull when you have uncommitted changes - commit your work first • if working on a feature, use a local branch, then this leaves the master open for other fixes • NEVER rebase or amend commits that you have pushed
  • 27. If you want it to work like cvs / svn • simply... • ‘pull’ at the start of the day and at regular intervals (as often as you’d checkout your code in cvs/svn) • ‘push’ after every commit
  • 29. github • http://github.com • popular git repository hosting site • home to many open source projects: • ruby on rails, jquery to name two...
  • 31. the plan... • get yourselves into pairs • person 1: • create a repository • check in some code • add person 2 to project
  • 32. the plan... • person 2: • pull code from person 1’s repository • make some changes and push back to repository • person 1: • pull these changes
  • 33. the plan... • somebody: • tag a release of the code • push this tag to github • stare in awe at the auto-generated tarball
  • 34. if we have time... • person 1: • create a local branch of the code • push this branch to github • person 2: • pull and work with this remote branch
  • 35. if we have more time • simulate a conflict and resolve it
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 44.
  • 45. git clone [paste ‘your clone url’] edit something add and commit git push origin master
  • 47. git pull origin master see if you have the changes from your partner
  • 49. git tag rel_1.0 git push --tags
  • 50.
  • 51.
  • 52. do we have time?
  • 54. git branch new_feature_foo git checkout new_feature_foo edit something, add and commit git push origin new_feature_foo
  • 56. git remote show origin git fetch origin new_feature_foo:new_feature_foo git fetch [repo] [remote_branch]:[local_branch]
  • 57. edit something, add and commit git push origin new_feature_foo cat .git/config - info on repository setup
  • 58.
  • 61. without doing a git pull! edit the file that person 2 just edited save, add and commit changes git push origin new_feature_foo O_o ooops...
  • 62. git pull origin new_feature_foo (git will inform you of a conflict) edit the file - resolve the conflict git add, commit, push conflict resolved! ^_^
  • 63. further reading • http://git-scm.com/documentation • http://learn.github.com/ • http://help.github.com/ • http://www.gitready.com/
  • 65. git config some setup i find useful...
  • 66. git config --global color.diff auto git config --global color.status auto git config --global color.branch auto git config --global color.interactive auto
  • 67. git config --global alias.st status git config --global alias.ci commit git config --global alias.co checkout git config --global alias.br branch
  • 68. git config --global core.excludesfile ~/.gitignore echo "*~" >~/.gitignore echo ".DS_Store" >>~/.gitignore