SlideShare a Scribd company logo
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
GitFor BillRun!
Copyrights © Moshe Kaplan
moshe.kaplan@brightaqua.com
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Git
For BillRun!
Moshe Kaplan
Scale Hacker
http://top-performance.blogspot.com
http://blogs.microsoft.co.il/vprnd
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
It’s all About
3
Scale
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
SOURCE CONTROL AND GIT
Introduction
4
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
GIT History
2002
Linus Torvald uses BitKeeper for tracking Linux
April, 2005
Linus writes his own SCM, GIT
June, 2005
GIT is officially used to track Linux
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Centralize VCS: C/S Model
Pros
• All versions of elements located on one place.
• Metadata & History are monosemantic
• Access control (permissions and triggers)
Cons
• Backup process is generally very complex
and needs downtime.
• Performance
• Dependence on Network status
Slide 6
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Distributed VCS: Everybody is an owner
Pros
• No server necessary
• It’s fast.
• Backup process is trivial + no downtime
Cons
• The distributed model is harder to understand.
• The revisions are not incremental numbers,
which make them harder to reference.
• Needs enough disk space for full repository and
work area on the client machine
• Potential loss of all changes until “push” operation
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Why Git?
• Decentralized
• Works offline (default)
• Flexible
• Lightweight
• Widely supported
• Better control
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
GIT Pros and ConsPros
• Resilience: No one repository has more data than any other
• Speed: Very fast operations compared to other VCS
• Space: Very effective compression mechanism
• Simplicity Object model is very simple
• Multi Platforms GIT supports all relevant OSs and all last Kernels
• Easy client installation Very simple installation and configuration procedure.
• OSS: GNU GPLv2.
Cons
• GIT does not have central support group.
• Version tree of file is absent & branches/commits tree is not intuitive.
• The revisions are not incremental numbers, which make them harder to reference
• Needs enough disk space for full repository and work area on the client machine
• Possible loss of all changes until “push” operation to one of “blessed” repos
• Commit messages are per changeset.
• Git does not track empty folders
• Git is really bad solution for big binaries in source control
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
De facto Standard
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Git theory and objects
http://blogs.mathworks.com/seth/2014/04/17/social-collaboration-using-git-for-model-based-design/
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Git submodules
• Link to external code repository
• Most useful for shared libraries
http://paynedigital.com/articles/2011/10/introduction-to-git-submodules
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Hooks
http://www.slideshare.net/bradleyd60/git-hooks-for-front-end-developers-52192325
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Gitflow
Common Methodology
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Build Machines and Continues deployments
15
http://tapetim.diq.co.il/36__The_Matrix,_1999,_Green_Falling_Code.htm
http://community.sharpdevelop.net/blogs/mattward/pages/FeatureTourUnitTesting.aspx
http://www.javalinux.it/wordpress/2008/05/19/subversion-branching-in-my-experience/
http://www.nytimes.com/2008/04/20/magazine/20Build-text.html
Automatic Tests
Merge to
Trunk
Feature
CODE
P1
P2
P3
Feedback
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Client Tools: Command Line
• http://git-scm.com/download/win
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Client Tools: SourceTree
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Eclipse for PHP
https://eclipse.org/pdt/
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Git/Eclipse Integration
http://www.eclipse.org/egit/?gclid
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Git Server Setup
• sudo apt-get install git-core
• sudo useradd git
• passwd git
• su git
• cd
• mkdir .ssh && chmod 700 .ssh
• touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
• cd /opt/git
• mkdir project.git
• cd project.git
• git init --bare
https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
First User Project
• cd myproject
• git init
• git add .
• git commit -m 'initial commit'
• git remote add origin git@gitserver:/opt/git/project.git
• git push origin master
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Other Users
• git clone git@gitserver:/opt/git/project.git
• cd project
• vim README
• git commit -am 'fix for the README file'
• git push origin master
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Eclipse/Git
1. File > Import 2. Team > Share Project 3. Git Ops
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
GETTING TO WORK GIT
Working
24
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Basic bash Commands
ls list files in current directory
cd change current directory
touch create a new blank file
rm remove a file
mv “move” - rename file
mkdir create a new directory
rmdir remove a directory
rm -rf remove directory and contents
more show the contents of a file
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Creating a repository
• git init <optional directory if not current>
• git add <file or directory name>
• git status
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
simone.soldateschi@rackspace.co.uk
Recap - The three states
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
simone.soldateschi@rackspace.co.uk
Basic commands
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Personal configuration
• Configure your git installation
• git config user.name <name>
• In current repository
• git config --global user.name <name>
• For all commits
• git config --global user.email <email>
• git config --global alias.<alias-name> <git-command>
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Where is it stored?
• Repository-specific settings
• <repo>/.git/config
• Where options set with the --global flag are stored
• ~/.gitconfig – User-specific settings.
• System-wide settings
• $(prefix)/etc/gitconfig
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Commits
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
What’s in a commit?
• Always Commit!
• Snapshots are committed to local repository
• Always lookups and complete files
• Much faster
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Creating commits
• Before commit always diff…
• git commit
• git commit -m “message”
• w/ message: use present tense readable comments!
• git commit –a
• To all files in tracked directory
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Amending commits
• History Rewrite… May cause loss of code!
• Used mostly to fix error in the previous commit
• Actually a complete new commit
• Only for private commits!
• git commit --amend
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Ignoring Files
• To Avoid Status Notifications
• .gitignore file
• Add relevant files such as compiled files: *.pyc
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Logs
• List, filter and search the snapshot log
• git log
• All logs
• git log –n <N>
• Last N commits
• git log <file name>
• Used for blaming
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Lab
• Basic work w/ Git
• 1. Create new repository
• 2. Add and Commit initial file README.txt
• 3. Modify and Commit initial file README.txt
• 4. Inspect log
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
TEAM WORK IN GIT
Work
38
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
simone.soldateschi@rackspace.co.uk
pull
do stuff
push
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
simone.soldateschi@rackspace.co.uk
local actions
and objects
remote
actions
and objects
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Diffs
• git status
• diff --git a/demo.txt b/demo.txt
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Fixing mistakes
• git checkout <revision id> <specific file>
• Modify files
• git checkout master
• git commit
• git revert
• Add new commit
• git reset
• Remove commits
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Fixing mistakes
git reset <commit>
• Get back to <commit> the staging area
• Working area left as previous enabling further commit
git reset --hard <commit>
• Working are is being reset as well
• No traces left
git reset --hard HEAD~2 Move back 2 commitsMove back 2 commits
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Cleanup
• git clean
• Clean all untracked files
• git clean –n
• dry run
• git clean –df
• Clean all
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches
• git checkout -b new-feature master
• Create a branch w/ new feature
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Merging
• git fetch origin
• git checkout master
• git merge origin/master
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Cloning
• When working w/ existing projects
• git clone <repo> <directory>
• git clone
ssh://john@example.com/path/to/proj.git
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Code Review
• git remote add <name> <url>
• Create link to peer repository
• git fetch <remote> <branch>
• Get Branch from peer repository
• git branch -r
• Show available remote branches
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Gitflow
Common Methodology
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Rebasing and Upstreams
• git rebase <base>
• New Commits
• Move features
• Change snapshot pointers
• Mostly for integrating your local dev to remote that is more
advanced
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Upstreams
• git pull == git fetch + git merge
• git pull <remote>
• git fetch <remote>
• git merge origin/<current-branch>
• git push <remote> <branch>
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
How to Do that?
• git checkout new-feature
• git rebase master
• git checkout master
• git merge new-feature
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Tags
• git tag -a <version> -m <commit message>
• git tag -a v1.0 -m ‘MVP launch’
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
bug123
master
> git checkout –b bug123
A B C
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
master
> git checkout master
A B C
D E
bug123
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
bug123
master
> git merge bug123
A B C D E
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
master
A B C D E
F G
bug456
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
master
A B C D E
> git rebase master
F’
G
’
bug456
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Branches Illustrated
master
A B C D E
456
> git checkout master
> git merge bug456
F’
G
’
bug456
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Developer GIT flow
 cd /home.local/<user>/git/<repo-name>/src/….
 git checkout [-b] <branch> (by default you are on master branch)
 Editing ↔ Compilation
 git add [<list of files/directories>|*|.] (add all relevant changes to changeset)
 git status (check the commit content)
 git pull (fetch & merge)
 git commit –m “comment” (local checkin)
 git show / git log
 git review [branch] (default branch is current one)
 git push [repo] [branch] (Just In the case you work without “Code review” system)
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Feature & R&D owners flow
Feature Owner Flow
git clone ssh://<user>@server/<repo name>
cd <repo_path>
git checkout <feature>
git merge develop
git mergetool
git review
R&D Owner Flow
git clone ssh://<user>@server/GIT/<repo name>.git
cd <repo path>
git checkout develop
git merge <feature>
git push origin develop
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Lab
• Group work w/ Git and BillRun:
• 1. Clone the code
• 2. Create an hotfix
• 3. Merge it to the develop branch
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
Thank You !
Moshe Kaplan
moshe.kaplan@brightaqua.com
054-2291978

More Related Content

PPTX
Git'in on Windows
ODP
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
PPTX
Git'in in 15
PPTX
Git n git hub
PPTX
Introduction to Git and Github
PDF
Introduction to Git, DrupalCamp LA 2015
PPTX
Introduction to git administration
Git'in on Windows
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Git'in in 15
Git n git hub
Introduction to Git and Github
Introduction to Git, DrupalCamp LA 2015
Introduction to git administration

What's hot (20)

PDF
Brief tutorial on Git
PDF
Introduction to Git
PPT
Git Introduction
PPTX
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
PPTX
Introduction to github slideshare
PPTX
Git & Github
PPTX
Git and git workflow best practice
PDF
Git and GitHub
PDF
Git and GitHub workflows
PPTX
Git 101
PDF
Git, GitHub and Open Source
PDF
Github Case Study By Amil Ali
PDF
沒有 GUI 的 Git
PDF
Starting with Git & GitHub
PPTX
Workflows using Git GitHub | Edureka
PPTX
Git kelvin
PDF
Git advanced
PDF
Software Versioning with Bitbucket and Eclipse
PDF
Git: A Getting Started Presentation
Brief tutorial on Git
Introduction to Git
Git Introduction
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Introduction to github slideshare
Git & Github
Git and git workflow best practice
Git and GitHub
Git and GitHub workflows
Git 101
Git, GitHub and Open Source
Github Case Study By Amil Ali
沒有 GUI 的 Git
Starting with Git & GitHub
Workflows using Git GitHub | Edureka
Git kelvin
Git advanced
Software Versioning with Bitbucket and Eclipse
Git: A Getting Started Presentation
Ad

Similar to Git Tutorial (20)

KEY
Let's Git this Party Started: An Introduction to Git and GitHub
PPTX
Git walkthrough
PPTX
Introduction to git and githhub with practicals.pptx
PDF
The Basics of Open Source Collaboration With Git and GitHub
ZIP
Beginner's Guide to Version Control with Git
PDF
Git 101: Git and GitHub for Beginners
PPT
Introduction to Git
PDF
PPTX
Git Basics for Software Version Management
PPTX
github ppt git ppt on git hub to know ab
PPTX
Learn Git - For Beginners and Intermediate levels
PDF
Enterprise git
PDF
Manage Org Changes Using the Force.com Migration Tool and Git
PPT
Git installation and configuration
PPTX
Mini-training: Let’s Git It!
PDF
ePOM - Fundamentals of Research Software Development - Code Version Control
PDF
O365Con18 - Git and GitHub - Rick van Rousselt
PPTX
Git and Github
PDF
Git training v10
PPTX
GIT.pptx
Let's Git this Party Started: An Introduction to Git and GitHub
Git walkthrough
Introduction to git and githhub with practicals.pptx
The Basics of Open Source Collaboration With Git and GitHub
Beginner's Guide to Version Control with Git
Git 101: Git and GitHub for Beginners
Introduction to Git
Git Basics for Software Version Management
github ppt git ppt on git hub to know ab
Learn Git - For Beginners and Intermediate levels
Enterprise git
Manage Org Changes Using the Force.com Migration Tool and Git
Git installation and configuration
Mini-training: Let’s Git It!
ePOM - Fundamentals of Research Software Development - Code Version Control
O365Con18 - Git and GitHub - Rick van Rousselt
Git and Github
Git training v10
GIT.pptx
Ad

More from Moshe Kaplan (20)

PDF
Spark and C Integration
PDF
Introduction to Big Data
PDF
Introduciton to Python
PDF
Creating Big Data: Methodology
PDF
Redis training for java software engineers
PDF
MongoDB training for java software engineers
PDF
MongoDB from Basics to Scale
PPTX
MongoDB Best Practices for Developers
PPTX
The api economy
PPTX
Big Data Workshop
PPT
Scale and Cloud Design Patterns
PPTX
Introduction to MongoDB
PPT
Web systems architecture, Performance and More
PPTX
Do Big Data and NoSQL Fit Your Needs?
PPTX
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
PPTX
MySQL Multi Master Replication
PDF
mongoDB Performance
PPT
Web Systems Architecture by Moshe Kaplan
PPTX
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
PPT
MySQL crash course by moshe kaplan
Spark and C Integration
Introduction to Big Data
Introduciton to Python
Creating Big Data: Methodology
Redis training for java software engineers
MongoDB training for java software engineers
MongoDB from Basics to Scale
MongoDB Best Practices for Developers
The api economy
Big Data Workshop
Scale and Cloud Design Patterns
Introduction to MongoDB
Web systems architecture, Performance and More
Do Big Data and NoSQL Fit Your Needs?
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
MySQL Multi Master Replication
mongoDB Performance
Web Systems Architecture by Moshe Kaplan
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
MySQL crash course by moshe kaplan

Recently uploaded (20)

PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Nekopoi APK 2025 free lastest update
PPTX
Introduction to Artificial Intelligence
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administraation Chapter 3
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
history of c programming in notes for students .pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ai tools demonstartion for schools and inter college
PTS Company Brochure 2025 (1).pdf.......
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo POS Development Services by CandidRoot Solutions
Nekopoi APK 2025 free lastest update
Introduction to Artificial Intelligence
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administraation Chapter 3
Wondershare Filmora 15 Crack With Activation Key [2025
2025 Textile ERP Trends: SAP, Odoo & Oracle
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Odoo Companies in India – Driving Business Transformation.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Operating system designcfffgfgggggggvggggggggg
history of c programming in notes for students .pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ai tools demonstartion for schools and inter college

Git Tutorial

  • 1. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! GitFor BillRun! Copyrights © Moshe Kaplan moshe.kaplan@brightaqua.com
  • 2. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Git For BillRun! Moshe Kaplan Scale Hacker http://top-performance.blogspot.com http://blogs.microsoft.co.il/vprnd
  • 3. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! It’s all About 3 Scale
  • 4. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! SOURCE CONTROL AND GIT Introduction 4
  • 5. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! GIT History 2002 Linus Torvald uses BitKeeper for tracking Linux April, 2005 Linus writes his own SCM, GIT June, 2005 GIT is officially used to track Linux
  • 6. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Centralize VCS: C/S Model Pros • All versions of elements located on one place. • Metadata & History are monosemantic • Access control (permissions and triggers) Cons • Backup process is generally very complex and needs downtime. • Performance • Dependence on Network status Slide 6
  • 7. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Distributed VCS: Everybody is an owner Pros • No server necessary • It’s fast. • Backup process is trivial + no downtime Cons • The distributed model is harder to understand. • The revisions are not incremental numbers, which make them harder to reference. • Needs enough disk space for full repository and work area on the client machine • Potential loss of all changes until “push” operation
  • 8. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Why Git? • Decentralized • Works offline (default) • Flexible • Lightweight • Widely supported • Better control
  • 9. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! GIT Pros and ConsPros • Resilience: No one repository has more data than any other • Speed: Very fast operations compared to other VCS • Space: Very effective compression mechanism • Simplicity Object model is very simple • Multi Platforms GIT supports all relevant OSs and all last Kernels • Easy client installation Very simple installation and configuration procedure. • OSS: GNU GPLv2. Cons • GIT does not have central support group. • Version tree of file is absent & branches/commits tree is not intuitive. • The revisions are not incremental numbers, which make them harder to reference • Needs enough disk space for full repository and work area on the client machine • Possible loss of all changes until “push” operation to one of “blessed” repos • Commit messages are per changeset. • Git does not track empty folders • Git is really bad solution for big binaries in source control
  • 10. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! De facto Standard
  • 11. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Git theory and objects http://blogs.mathworks.com/seth/2014/04/17/social-collaboration-using-git-for-model-based-design/
  • 12. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Git submodules • Link to external code repository • Most useful for shared libraries http://paynedigital.com/articles/2011/10/introduction-to-git-submodules
  • 13. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Hooks http://www.slideshare.net/bradleyd60/git-hooks-for-front-end-developers-52192325
  • 14. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Gitflow Common Methodology
  • 15. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Build Machines and Continues deployments 15 http://tapetim.diq.co.il/36__The_Matrix,_1999,_Green_Falling_Code.htm http://community.sharpdevelop.net/blogs/mattward/pages/FeatureTourUnitTesting.aspx http://www.javalinux.it/wordpress/2008/05/19/subversion-branching-in-my-experience/ http://www.nytimes.com/2008/04/20/magazine/20Build-text.html Automatic Tests Merge to Trunk Feature CODE P1 P2 P3 Feedback
  • 16. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Client Tools: Command Line • http://git-scm.com/download/win
  • 17. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Client Tools: SourceTree
  • 18. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Eclipse for PHP https://eclipse.org/pdt/
  • 19. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Git/Eclipse Integration http://www.eclipse.org/egit/?gclid
  • 20. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Git Server Setup • sudo apt-get install git-core • sudo useradd git • passwd git • su git • cd • mkdir .ssh && chmod 700 .ssh • touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys • cd /opt/git • mkdir project.git • cd project.git • git init --bare https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
  • 21. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! First User Project • cd myproject • git init • git add . • git commit -m 'initial commit' • git remote add origin git@gitserver:/opt/git/project.git • git push origin master
  • 22. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Other Users • git clone git@gitserver:/opt/git/project.git • cd project • vim README • git commit -am 'fix for the README file' • git push origin master
  • 23. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Eclipse/Git 1. File > Import 2. Team > Share Project 3. Git Ops
  • 24. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! GETTING TO WORK GIT Working 24
  • 25. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Basic bash Commands ls list files in current directory cd change current directory touch create a new blank file rm remove a file mv “move” - rename file mkdir create a new directory rmdir remove a directory rm -rf remove directory and contents more show the contents of a file
  • 26. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Creating a repository • git init <optional directory if not current> • git add <file or directory name> • git status
  • 27. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! simone.soldateschi@rackspace.co.uk Recap - The three states
  • 28. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! simone.soldateschi@rackspace.co.uk Basic commands
  • 29. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Personal configuration • Configure your git installation • git config user.name <name> • In current repository • git config --global user.name <name> • For all commits • git config --global user.email <email> • git config --global alias.<alias-name> <git-command>
  • 30. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Where is it stored? • Repository-specific settings • <repo>/.git/config • Where options set with the --global flag are stored • ~/.gitconfig – User-specific settings. • System-wide settings • $(prefix)/etc/gitconfig
  • 31. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Commits
  • 32. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! What’s in a commit? • Always Commit! • Snapshots are committed to local repository • Always lookups and complete files • Much faster
  • 33. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Creating commits • Before commit always diff… • git commit • git commit -m “message” • w/ message: use present tense readable comments! • git commit –a • To all files in tracked directory
  • 34. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Amending commits • History Rewrite… May cause loss of code! • Used mostly to fix error in the previous commit • Actually a complete new commit • Only for private commits! • git commit --amend
  • 35. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Ignoring Files • To Avoid Status Notifications • .gitignore file • Add relevant files such as compiled files: *.pyc
  • 36. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Logs • List, filter and search the snapshot log • git log • All logs • git log –n <N> • Last N commits • git log <file name> • Used for blaming
  • 37. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Lab • Basic work w/ Git • 1. Create new repository • 2. Add and Commit initial file README.txt • 3. Modify and Commit initial file README.txt • 4. Inspect log
  • 38. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! TEAM WORK IN GIT Work 38
  • 39. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! simone.soldateschi@rackspace.co.uk pull do stuff push
  • 40. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! simone.soldateschi@rackspace.co.uk local actions and objects remote actions and objects
  • 41. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Diffs • git status • diff --git a/demo.txt b/demo.txt
  • 42. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Fixing mistakes • git checkout <revision id> <specific file> • Modify files • git checkout master • git commit • git revert • Add new commit • git reset • Remove commits
  • 43. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Fixing mistakes git reset <commit> • Get back to <commit> the staging area • Working area left as previous enabling further commit git reset --hard <commit> • Working are is being reset as well • No traces left git reset --hard HEAD~2 Move back 2 commitsMove back 2 commits
  • 44. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Cleanup • git clean • Clean all untracked files • git clean –n • dry run • git clean –df • Clean all
  • 45. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches • git checkout -b new-feature master • Create a branch w/ new feature
  • 46. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Merging • git fetch origin • git checkout master • git merge origin/master
  • 47. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Cloning • When working w/ existing projects • git clone <repo> <directory> • git clone ssh://john@example.com/path/to/proj.git
  • 48. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Code Review • git remote add <name> <url> • Create link to peer repository • git fetch <remote> <branch> • Get Branch from peer repository • git branch -r • Show available remote branches
  • 49. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Gitflow Common Methodology
  • 50. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Rebasing and Upstreams • git rebase <base> • New Commits • Move features • Change snapshot pointers • Mostly for integrating your local dev to remote that is more advanced
  • 51. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Upstreams • git pull == git fetch + git merge • git pull <remote> • git fetch <remote> • git merge origin/<current-branch> • git push <remote> <branch>
  • 52. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! How to Do that? • git checkout new-feature • git rebase master • git checkout master • git merge new-feature
  • 53. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Tags • git tag -a <version> -m <commit message> • git tag -a v1.0 -m ‘MVP launch’
  • 54. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated bug123 master > git checkout –b bug123 A B C
  • 55. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated master > git checkout master A B C D E bug123
  • 56. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated bug123 master > git merge bug123 A B C D E
  • 57. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated master A B C D E F G bug456
  • 58. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated master A B C D E > git rebase master F’ G ’ bug456
  • 59. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Branches Illustrated master A B C D E 456 > git checkout master > git merge bug456 F’ G ’ bug456
  • 60. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Developer GIT flow  cd /home.local/<user>/git/<repo-name>/src/….  git checkout [-b] <branch> (by default you are on master branch)  Editing ↔ Compilation  git add [<list of files/directories>|*|.] (add all relevant changes to changeset)  git status (check the commit content)  git pull (fetch & merge)  git commit –m “comment” (local checkin)  git show / git log  git review [branch] (default branch is current one)  git push [repo] [branch] (Just In the case you work without “Code review” system)
  • 61. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Feature & R&D owners flow Feature Owner Flow git clone ssh://<user>@server/<repo name> cd <repo_path> git checkout <feature> git merge develop git mergetool git review R&D Owner Flow git clone ssh://<user>@server/GIT/<repo name>.git cd <repo path> git checkout develop git merge <feature> git push origin develop
  • 62. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Lab • Group work w/ Git and BillRun: • 1. Clone the code • 2. Create an hotfix • 3. Merge it to the develop branch
  • 63. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!
  • 64. © All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun!© All rights reserved: Moshe Kaplan© All rights reserved: Moshe Kaplan Git for BillRun! Thank You ! Moshe Kaplan moshe.kaplan@brightaqua.com 054-2291978