SlideShare a Scribd company logo
1 of 47
Download to read offline
Git walkthrough
@modsaid
Outline
● Source Control
● Git Basics
● Configuration
● Viewing history
● Undoing
● Aliases
● Tagging
● Branching
● Remotes
● Bare repos
● Hosting: Github, bitbucket, ...
● Git 2.0+
Version
Control
System
Centralized
Version
Control
System
Distributed
Version
Control
System
Git Basics
● Local Repo ( .git )
● Working directory
Git Basics - The 3 States
Git Basics
● git init
● git status
● git add
● git commit
● git reset
● git clone
● git mv
● git rm
● git blame
● git push
● git pull
Git Basics - committing
# Initializing a new repo
$ git init .
# Staging
$ git add .
$ git add -A
# committing
$ git commit -m “initial commit”
Git Basics - committing
$ git status
# diff (working vs staged)
$ git diff
# diff (staged vs committed)
$ git diff -s
# Stage and commit in one shot
$ git commit -a -m “direct staging and commit”
Git Configuration
● System
● User
● repo
/etc/gitconfig
~/.gitconfig or ~/.config/git/config
.git/config
Git Configuration
git config --system
git config --global
git config --local
Git Configuration
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.
com
$ git config --global core.editor emacs
$ git config --list
$ git config user.name
Viewing History
$ git log
$ git log -p -2
$ git log --stat
$ git log --grep adding
$ git log --since=2.weeks
$ git log --Sfunction_name
$ git log --pretty=oneline
$ git log --pretty=format:"%h - %an, %ar : %s"
Viewing History
$ git log --pretty=format:"%ad %an : %s " --
date=short
$ git log --pretty=oneline --since=”2012-12-20”
--until=”2013-01-01” -5
$ git log --pretty=oneline | wc -l #no of commits
$ git log --pretty=format:%cd --date=short |
uniq | wc -l #no of working days
Viewing History
$ git shortlog
$ git shortlog -s | wc -l #no of devs
$ git shortlog -se # list of devs
#no of coding days
$ git log --pretty=format:”%ad” --date=short |
uniq | wc -l
Viewing History - mapping names
$ git shortlog -se | grep -i john
6 John Doe <john.doe@espace.com.eg>
10 John-Doe <john.doe@espace.com.eg>
4 John.Doe <john.doe@espace.com.eg>
$ vim .mailmap
name1 name2 name3 mail@example.com
name4 mail@example.com
$ git shortlog -se > .mailmap
Undoing
git commit --amend
# Changing commit message
$ git commit --amend -m “better commit message”
# Adding forgotten file
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
Undoing
#Unstaging
$ git add .
$ git status
$ git reset HEAD benchmarks.rb
#dropping local commits <DANGER>
git reset --hard HEAD~3
Git Aliases
$ git config --global alias.co checkout
$ git config --global alias.ci commit
$ git config --global alias.st status
$ git config alias.showdevs 'shortlog -s'
$ git config --global alias.unstage 'reset HEAD
--'
Tagging
● Lightweight: pointer to specific commit
$ git tag before-optimization
● Annotated: full objects, checksummed,
contains tagger info, suitable for
releases
$ git tag -a v1.4 -m 'my version 1.4'
Tagging
#Tagging later
$ git tag -a v1.2 9fceb02
$ git show v1.2
$ git push origin v1.5
$ git push origin --tags
Branching
$ git branch #List current branches
$ git branch newone # create a new branch newone
$ git checkout newone # switch to newone branch
# create branch and switch in one step
$ git checkout -b newtwo
Branching
# Committing on master
Branching
$ git branch testing
Branching
Branching
$ git checkout testing
Branching
$ git commit -a -m “some change”
Branching
$ git checkout master
Branching
$ git commit -a -m “master commit”
Branching - Merging
$ git merge testing
# in case of conflicts (failed auto merge)
$ git mergetool
Branching - Merging
fast-forward
git merge feature
no fast-forward
git merge --no-ff feature
Remotes
# Listing remotes
$ git remote
$ git remote -v
# Adding a remote
$ git remote add [shortname] [url]
$ git remote show origin
Remotes
# Fetching updates
$ git fetch [remote-name]
$ git remote rename pb paul
$ git remote rm paul
Bare Repos
● git repo with no working directory
● The git server side
$ git init --bare .
# Cloning (backup)
$ git clone --bare git@github.com:modsaid/git-demo2.git
# Restoring
$ git push --mirror git@bitbucket.org:modsaid/git-demo2.git
Hosting: github, bitbucket
● Github: the most popular, free public repos
● Bitbucket: free private with limited
collaborators
● A lot others
Github
● Exploring repos
● Pull Requests
● Contribution to repos:
○ Fork
○ Fix/Add
○ Send pull request
https://help.github.com/articles/fork-a-repo/
Latest git
The latest git release today is 2.3.3
Installing the latest git (2.3)
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
What’s new in Git 2.0
“From the point of view of end-users who are totally new to
Git, this release will give them the defaults that are vastly
improved compared to the older versions, but at the same
time, for existing users, this release is designed to be as
low-impact as possible as long as they have been following
recent releases along.”
● Better Defaults
what’s new? git push
pre git 2.0
● Default: matching
starting git 2.0
● Default: simple
git config push.default
● ( nothing | current | upstream | simple | matching )
what’s new? git add -u
pre git 2.0
● stage files in working directory
starting git 2.0
● stage files in the Repo Directory
what’s new? git diff -q
pre git 2.0
● valid option
starting git 2.0
● Removed
Do not display deleted files during git diff
what’s new?
● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.0.0.txt
● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.1.0.txt
● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.2.0.txt
● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.3.0.txt
Resources
● Pro Git, Second Edition
By: Scott Chacon; Ben Straub
Publisher: Apress
Pub. Date: November 19, 2014
● git help COMMAND (man pages)
● Git Recipes by BasayelSaid
Thank You

More Related Content

What's hot

Clojure + MongoDB on Heroku
Clojure + MongoDB on HerokuClojure + MongoDB on Heroku
Clojure + MongoDB on HerokuNaoyuki Kakuda
 
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
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about gitSothearin Ren
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
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
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
Python_Session
Python_SessionPython_Session
Python_Sessionsiva ram
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Mizan Riqzia
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commandsZakaria Bouazza
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Gitfajran
 
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshopŁukasz Lalik
 
Eat my data
Eat my dataEat my data
Eat my dataPeng Zuo
 
Git it on (includes git hub)
Git it on (includes git hub)Git it on (includes git hub)
Git it on (includes git hub)Martin Bing
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji3camp
 

What's hot (20)

Clojure + MongoDB on Heroku
Clojure + MongoDB on HerokuClojure + MongoDB on Heroku
Clojure + MongoDB on Heroku
 
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
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
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
 
Basic git
Basic gitBasic git
Basic git
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Python_Session
Python_SessionPython_Session
Python_Session
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
Git
GitGit
Git
 
Git Memento of basic commands
Git Memento of basic commandsGit Memento of basic commands
Git Memento of basic commands
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Git
 
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshop
 
Eat my data
Eat my dataEat my data
Eat my data
 
Git it on (includes git hub)
Git it on (includes git hub)Git it on (includes git hub)
Git it on (includes git hub)
 
GIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersjiGIT rozproszony system kontroli wersji
GIT rozproszony system kontroli wersji
 
Do you know GIT?
Do you know GIT?Do you know GIT?
Do you know GIT?
 
Git SCM
Git SCMGit SCM
Git SCM
 

Similar to Git walkthrough

Getting some Git
Getting some GitGetting some Git
Getting some GitBADR
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmdsrinathcox
 
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
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceForest Mars
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucketazwildcat
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with GitDmitry Sheiko
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleGaurav Kumar Garg
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 

Similar to Git walkthrough (20)

Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
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
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Git
GitGit
Git
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 

More from Mahmoud Said

IT Operations for Web Developers
IT Operations for Web DevelopersIT Operations for Web Developers
IT Operations for Web DevelopersMahmoud Said
 
Beginner walkthrough to git and github
Beginner walkthrough to git and githubBeginner walkthrough to git and github
Beginner walkthrough to git and githubMahmoud Said
 
Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalkIntroduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalkMahmoud Said
 
Linux Administration for Developers
Linux Administration for DevelopersLinux Administration for Developers
Linux Administration for DevelopersMahmoud Said
 
ebda2, Business plan - Omar Shawky
ebda2, Business plan - Omar Shawkyebda2, Business plan - Omar Shawky
ebda2, Business plan - Omar ShawkyMahmoud Said
 
Google ebda2 - eCommerce - Souq.com
Google ebda2 - eCommerce - Souq.comGoogle ebda2 - eCommerce - Souq.com
Google ebda2 - eCommerce - Souq.comMahmoud Said
 
Entrepreneurship 101
Entrepreneurship 101Entrepreneurship 101
Entrepreneurship 101Mahmoud Said
 

More from Mahmoud Said (7)

IT Operations for Web Developers
IT Operations for Web DevelopersIT Operations for Web Developers
IT Operations for Web Developers
 
Beginner walkthrough to git and github
Beginner walkthrough to git and githubBeginner walkthrough to git and github
Beginner walkthrough to git and github
 
Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalkIntroduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalk
 
Linux Administration for Developers
Linux Administration for DevelopersLinux Administration for Developers
Linux Administration for Developers
 
ebda2, Business plan - Omar Shawky
ebda2, Business plan - Omar Shawkyebda2, Business plan - Omar Shawky
ebda2, Business plan - Omar Shawky
 
Google ebda2 - eCommerce - Souq.com
Google ebda2 - eCommerce - Souq.comGoogle ebda2 - eCommerce - Souq.com
Google ebda2 - eCommerce - Souq.com
 
Entrepreneurship 101
Entrepreneurship 101Entrepreneurship 101
Entrepreneurship 101
 

Recently uploaded

Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
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
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
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
 
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
 
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
 
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
 
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 pragmaticsAndrey Dotsenko
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
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
 
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
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
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
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
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
 
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
 
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
 
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...
 
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
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
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...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
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
 
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...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

Git walkthrough

  • 2. Outline ● Source Control ● Git Basics ● Configuration ● Viewing history ● Undoing ● Aliases ● Tagging ● Branching ● Remotes ● Bare repos ● Hosting: Github, bitbucket, ... ● Git 2.0+
  • 6. Git Basics ● Local Repo ( .git ) ● Working directory
  • 7. Git Basics - The 3 States
  • 8. Git Basics ● git init ● git status ● git add ● git commit ● git reset ● git clone ● git mv ● git rm ● git blame ● git push ● git pull
  • 9. Git Basics - committing # Initializing a new repo $ git init . # Staging $ git add . $ git add -A # committing $ git commit -m “initial commit”
  • 10. Git Basics - committing $ git status # diff (working vs staged) $ git diff # diff (staged vs committed) $ git diff -s # Stage and commit in one shot $ git commit -a -m “direct staging and commit”
  • 11. Git Configuration ● System ● User ● repo /etc/gitconfig ~/.gitconfig or ~/.config/git/config .git/config
  • 12. Git Configuration git config --system git config --global git config --local
  • 13. Git Configuration $ git config --global user.name "John Doe" $ git config --global user.email johndoe@example. com $ git config --global core.editor emacs $ git config --list $ git config user.name
  • 14. Viewing History $ git log $ git log -p -2 $ git log --stat $ git log --grep adding $ git log --since=2.weeks $ git log --Sfunction_name $ git log --pretty=oneline $ git log --pretty=format:"%h - %an, %ar : %s"
  • 15.
  • 16. Viewing History $ git log --pretty=format:"%ad %an : %s " -- date=short $ git log --pretty=oneline --since=”2012-12-20” --until=”2013-01-01” -5 $ git log --pretty=oneline | wc -l #no of commits $ git log --pretty=format:%cd --date=short | uniq | wc -l #no of working days
  • 17. Viewing History $ git shortlog $ git shortlog -s | wc -l #no of devs $ git shortlog -se # list of devs #no of coding days $ git log --pretty=format:”%ad” --date=short | uniq | wc -l
  • 18. Viewing History - mapping names $ git shortlog -se | grep -i john 6 John Doe <john.doe@espace.com.eg> 10 John-Doe <john.doe@espace.com.eg> 4 John.Doe <john.doe@espace.com.eg> $ vim .mailmap name1 name2 name3 mail@example.com name4 mail@example.com $ git shortlog -se > .mailmap
  • 19. Undoing git commit --amend # Changing commit message $ git commit --amend -m “better commit message” # Adding forgotten file $ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend
  • 20. Undoing #Unstaging $ git add . $ git status $ git reset HEAD benchmarks.rb #dropping local commits <DANGER> git reset --hard HEAD~3
  • 21. Git Aliases $ git config --global alias.co checkout $ git config --global alias.ci commit $ git config --global alias.st status $ git config alias.showdevs 'shortlog -s' $ git config --global alias.unstage 'reset HEAD --'
  • 22. Tagging ● Lightweight: pointer to specific commit $ git tag before-optimization ● Annotated: full objects, checksummed, contains tagger info, suitable for releases $ git tag -a v1.4 -m 'my version 1.4'
  • 23. Tagging #Tagging later $ git tag -a v1.2 9fceb02 $ git show v1.2 $ git push origin v1.5 $ git push origin --tags
  • 24. Branching $ git branch #List current branches $ git branch newone # create a new branch newone $ git checkout newone # switch to newone branch # create branch and switch in one step $ git checkout -b newtwo
  • 29. Branching $ git commit -a -m “some change”
  • 31. Branching $ git commit -a -m “master commit”
  • 32. Branching - Merging $ git merge testing # in case of conflicts (failed auto merge) $ git mergetool
  • 33. Branching - Merging fast-forward git merge feature no fast-forward git merge --no-ff feature
  • 34. Remotes # Listing remotes $ git remote $ git remote -v # Adding a remote $ git remote add [shortname] [url] $ git remote show origin
  • 35. Remotes # Fetching updates $ git fetch [remote-name] $ git remote rename pb paul $ git remote rm paul
  • 36. Bare Repos ● git repo with no working directory ● The git server side $ git init --bare . # Cloning (backup) $ git clone --bare git@github.com:modsaid/git-demo2.git # Restoring $ git push --mirror git@bitbucket.org:modsaid/git-demo2.git
  • 37. Hosting: github, bitbucket ● Github: the most popular, free public repos ● Bitbucket: free private with limited collaborators ● A lot others
  • 38. Github ● Exploring repos ● Pull Requests ● Contribution to repos: ○ Fork ○ Fix/Add ○ Send pull request https://help.github.com/articles/fork-a-repo/
  • 39. Latest git The latest git release today is 2.3.3
  • 40. Installing the latest git (2.3) $ sudo add-apt-repository ppa:git-core/ppa $ sudo apt-get update $ sudo apt-get install git
  • 41. What’s new in Git 2.0 “From the point of view of end-users who are totally new to Git, this release will give them the defaults that are vastly improved compared to the older versions, but at the same time, for existing users, this release is designed to be as low-impact as possible as long as they have been following recent releases along.” ● Better Defaults
  • 42. what’s new? git push pre git 2.0 ● Default: matching starting git 2.0 ● Default: simple git config push.default ● ( nothing | current | upstream | simple | matching )
  • 43. what’s new? git add -u pre git 2.0 ● stage files in working directory starting git 2.0 ● stage files in the Repo Directory
  • 44. what’s new? git diff -q pre git 2.0 ● valid option starting git 2.0 ● Removed Do not display deleted files during git diff
  • 45. what’s new? ● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.0.0.txt ● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.1.0.txt ● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.2.0.txt ● https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.3.0.txt
  • 46. Resources ● Pro Git, Second Edition By: Scott Chacon; Ben Straub Publisher: Apress Pub. Date: November 19, 2014 ● git help COMMAND (man pages) ● Git Recipes by BasayelSaid