SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Git 101
@jenssegers
In a world without Git
Distributed version control
‱   Speed

‱   Simple

‱   Non-linear development

‱   Fully distributed

‱   Large projects
Snapshots, no ∆
Distributed

                 Hannes

Pieter




                       Jens
Miet
Distributed and managed

              Hannes

    Pieter




                   Jens
    Miet
Github
                  Hannes

Pieter




                       Jens
What is Github?


‱   Repository hosting service

‱   Visualization of changes

‱   Issue tracker
Installing Git

‱   Windows
    Git Bash with MinGW
                           git-scm.com
‱   OSX and Linux
    Terminal
Git conïŹguration


$ git config --global user.name “Your Name”

$ git config --global user.email “your@email.com”
A new github repository


             git@github.com:user/Hello.git
Creating a local repository

$ mkdir Hello

$ cd Hello

$ git init

Initialized empty Git repository in Hello/.git/

$ git remote add origin git@github.com:user/Hello.git
Git Basics
git add
Track ïŹles for the next snapshot
$ git add README

$ git add subfolder/


Add all ïŹles (including deleted ïŹles)
$ git add -A
git rm

Opposite of add, untracks ïŹle
$ git rm README


Recursive
$ git rm -r subfolder/
git commit

Create a snapshot of all the added ïŹles
$ git commit -m “Adding readme”

[master] created d9e1758: “Adding readme”
1 files changed, 1 insertions(+), 0 deletions(-)


Always add an appropriate commit message!
git commit (2)
Automatically detect changed and deleted ïŹles
$ git commit -am “Adding readme”


Update a previous commit
$ git commit -am “GUI refactoring”

$ git add new_file

$ git commit --amend
git push

Push commit snapshots to a remote repository
$ git push [remote] [branch]


$ git push origin master

Writing objects: 100% (3/3), 225 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
git pull

Pull updates from a remote repository
$ git pull [remote] [branch]


$ git pull origin master

remote: Total 3 (delta 0), reused 0 (delta 0)
Updating d9e1758..c3e12cc
git clone

Work on an existing repository
$ git clone [origin]


$ git clone https://github.com/user/repository.git

Cloning into ...
Unpacking objects: 100%, done.
ConïŹ‚icts
ConïŹ‚icts

A ïŹle was modiïŹed since the last pull

$ git push origin master

! [rejected]             master -> master (non-fast-forward)
Inspecting the conïŹ‚ict
Update your repository
$ git pull


View conïŹ‚ict info
$ git status

Unmerged paths:
both modified:           README
Resolving the conïŹ‚ict
Open the conïŹ‚icted ïŹle in your favorite editor
$ nano README


<<<<<<< HEAD
Yes, this is Dog?       ]       local repository
=======
Who is Dog?
>>>>>>> a0b0bf3
                        ]       remote repository
Push merged ïŹle


$ git add README

$ git commit -m “Merging”

$ git push origin master
Branching
Branches
Typical branches
‱   Master
    The latest stable version of the project

‱   Staging
    The branch where the a beta version is tested before it is merged
    into the master branch

‱   Feature X
    A branch where a speciïŹc feature is being developed
Creating a branch

From the base branch
$ git branch feature-x


Switching to the new branch
$ git checkout feature-x
Merging a branch

Switch to the base branch you want to merge in
$ git checkout master


Merge with the branch
$ git merge staging
Updating a branch


Update a feature branch with master branch bug ïŹxes
$ git checkout feature-x

$ git merge master
Removing a branch


$ git branch -D feature-useless
Tips and tricks
.gitignore
A list of ïŹles that should be ignored
# OS generated files
.DS_Store
.Trashes
Thumbs.db

# Config
Config.php
When all hope is lost


Revert all changes to the last pulled version
$ git reset --hard HEAD
Credential cache

Add cache to credentials to prevent typing username and password
over and over again
$ git config --global credential.helper cache


Default cache is 15 minutes, to change cache use
$ git config credential.helper 'cache --timeout=3600'
SSH keys
WARNING! Only when you do not have an existing key pair

$ ssh-keygen -t rsa -C "your@email.com"

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/you/.ssh/
id_rsa): [Press enter]

Enter passphrase (empty for no passphrase): [Type a
passphrase]
SSH keys (2)
Add your public SSH key to your github account (account settings)
$ cat ~/.ssh/id_rsa.pub


Test your settings
$ ssh -T git@github.com

Hi username! You've successfully authenticated, but
GitHub does not provide shell access.
Good luck


                    thanks
Tim De Pauw, Pieter Colpaert, Hannes Van De Vreken

Weitere Àhnliche Inhalte

Was ist angesagt?

Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Gitgittower
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)Salvatore Cordiano
 
Version control system & how to use git
Version control system & how to use git Version control system & how to use git
Version control system & how to use git Ahmed Dalatony
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon MelbournePaal Ringstad
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and GithubSomkiat Puisungnoen
 
Git - a overview for beginners
Git - a overview for beginnersGit - a overview for beginners
Git - a overview for beginnersAnton Pirker
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAtlassian
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Git real slides
Git real slidesGit real slides
Git real slidesLucas Couto
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners Anurag Upadhaya
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about gitSothearin Ren
 
Git tutorial
Git tutorial Git tutorial
Git tutorial TingYen Lee
 
Git ritesh venture_pact
Git ritesh venture_pactGit ritesh venture_pact
Git ritesh venture_pactriteshtandon23
 

Was ist angesagt? (20)

Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Version control system & how to use git
Version control system & how to use git Version control system & how to use git
Version control system & how to use git
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon Melbourne
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git - a overview for beginners
Git - a overview for beginnersGit - a overview for beginners
Git - a overview for beginners
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git training
Git trainingGit training
Git training
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Git ritesh venture_pact
Git ritesh venture_pactGit ritesh venture_pact
Git ritesh venture_pact
 
Git101
Git101Git101
Git101
 

Ähnlich wie Git101

簥斟介çŽčgit
簥斟介çŽčgit簥斟介çŽčgit
簥斟介çŽčgitGrace Chien
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.comdropsolid
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinuxShubham Verma
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Git presentation
Git presentationGit presentation
Git presentationJames Cuzella
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros DeveloperNyros Technologies
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12auNguyen Van Hung
 
sample.pptx
sample.pptxsample.pptx
sample.pptxUshaSuray
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub WorkshopLuis Lamadrid
 
Hello git
Hello git Hello git
Hello git Josh Dvir
 

Ähnlich wie Git101 (20)

簥斟介çŽčgit
簥斟介çŽčgit簥斟介çŽčgit
簥斟介çŽčgit
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git session Dropsolid.com
Git session Dropsolid.comGit session Dropsolid.com
Git session Dropsolid.com
 
Git basics
Git basicsGit basics
Git basics
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
 
GitSetupLinux
GitSetupLinuxGitSetupLinux
GitSetupLinux
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git presentation
Git presentationGit presentation
Git presentation
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Git
GitGit
Git
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
 
Hello git
Hello git Hello git
Hello git
 

KĂŒrzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂșjo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

KĂŒrzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Git101

  • 2. In a world without Git
  • 3. Distributed version control ‱ Speed ‱ Simple ‱ Non-linear development ‱ Fully distributed ‱ Large projects
  • 5. Distributed Hannes Pieter Jens Miet
  • 6. Distributed and managed Hannes Pieter Jens Miet
  • 7. Github Hannes Pieter Jens
  • 8. What is Github? ‱ Repository hosting service ‱ Visualization of changes ‱ Issue tracker
  • 9. Installing Git ‱ Windows Git Bash with MinGW git-scm.com ‱ OSX and Linux Terminal
  • 10. Git conïŹguration $ git config --global user.name “Your Name” $ git config --global user.email “your@email.com”
  • 11. A new github repository git@github.com:user/Hello.git
  • 12. Creating a local repository $ mkdir Hello $ cd Hello $ git init Initialized empty Git repository in Hello/.git/ $ git remote add origin git@github.com:user/Hello.git
  • 14. git add Track ïŹles for the next snapshot $ git add README $ git add subfolder/ Add all ïŹles (including deleted ïŹles) $ git add -A
  • 15. git rm Opposite of add, untracks ïŹle $ git rm README Recursive $ git rm -r subfolder/
  • 16. git commit Create a snapshot of all the added ïŹles $ git commit -m “Adding readme” [master] created d9e1758: “Adding readme” 1 files changed, 1 insertions(+), 0 deletions(-) Always add an appropriate commit message!
  • 17. git commit (2) Automatically detect changed and deleted ïŹles $ git commit -am “Adding readme” Update a previous commit $ git commit -am “GUI refactoring” $ git add new_file $ git commit --amend
  • 18. git push Push commit snapshots to a remote repository $ git push [remote] [branch] $ git push origin master Writing objects: 100% (3/3), 225 bytes, done. Total 3 (delta 0), reused 0 (delta 0)
  • 19. git pull Pull updates from a remote repository $ git pull [remote] [branch] $ git pull origin master remote: Total 3 (delta 0), reused 0 (delta 0) Updating d9e1758..c3e12cc
  • 20. git clone Work on an existing repository $ git clone [origin] $ git clone https://github.com/user/repository.git Cloning into ... Unpacking objects: 100%, done.
  • 22. ConïŹ‚icts A ïŹle was modiïŹed since the last pull $ git push origin master ! [rejected] master -> master (non-fast-forward)
  • 23. Inspecting the conïŹ‚ict Update your repository $ git pull View conïŹ‚ict info $ git status Unmerged paths: both modified: README
  • 24. Resolving the conïŹ‚ict Open the conïŹ‚icted ïŹle in your favorite editor $ nano README <<<<<<< HEAD Yes, this is Dog? ] local repository ======= Who is Dog? >>>>>>> a0b0bf3 ] remote repository
  • 25. Push merged ïŹle $ git add README $ git commit -m “Merging” $ git push origin master
  • 28. Typical branches ‱ Master The latest stable version of the project ‱ Staging The branch where the a beta version is tested before it is merged into the master branch ‱ Feature X A branch where a speciïŹc feature is being developed
  • 29. Creating a branch From the base branch $ git branch feature-x Switching to the new branch $ git checkout feature-x
  • 30. Merging a branch Switch to the base branch you want to merge in $ git checkout master Merge with the branch $ git merge staging
  • 31. Updating a branch Update a feature branch with master branch bug ïŹxes $ git checkout feature-x $ git merge master
  • 32. Removing a branch $ git branch -D feature-useless
  • 34. .gitignore A list of ïŹles that should be ignored # OS generated files .DS_Store .Trashes Thumbs.db # Config Config.php
  • 35. When all hope is lost Revert all changes to the last pulled version $ git reset --hard HEAD
  • 36. Credential cache Add cache to credentials to prevent typing username and password over and over again $ git config --global credential.helper cache Default cache is 15 minutes, to change cache use $ git config credential.helper 'cache --timeout=3600'
  • 37. SSH keys WARNING! Only when you do not have an existing key pair $ ssh-keygen -t rsa -C "your@email.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/you/.ssh/ id_rsa): [Press enter] Enter passphrase (empty for no passphrase): [Type a passphrase]
  • 38. SSH keys (2) Add your public SSH key to your github account (account settings) $ cat ~/.ssh/id_rsa.pub Test your settings $ ssh -T git@github.com Hi username! You've successfully authenticated, but GitHub does not provide shell access.
  • 39. Good luck thanks Tim De Pauw, Pieter Colpaert, Hannes Van De Vreken