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

What's hot

Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
Nap Ramirez
 

What's hot (20)

Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Git 101
Git 101Git 101
Git 101
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
 
Github Case Study By Amil Ali
Github Case Study By Amil AliGithub Case Study By Amil Ali
Github Case Study By Amil Ali
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Workflows using Git GitHub | Edureka
Workflows using Git GitHub | EdurekaWorkflows using Git GitHub | Edureka
Workflows using Git GitHub | Edureka
 
Git kelvin
Git   kelvinGit   kelvin
Git kelvin
 
Git advanced
Git advancedGit advanced
Git advanced
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
 
Intro to Git & GitHub
Intro to Git & GitHubIntro to Git & GitHub
Intro to Git & GitHub
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 

Similar to Git Tutorial

Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Robert Lee-Cann
 
Enterprise git
Enterprise gitEnterprise git
Enterprise git
Pedro Melo
 
3 Git
3 Git3 Git

Similar to Git Tutorial (20)

Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
 
Enterprise git
Enterprise gitEnterprise git
Enterprise git
 
Manage Org Changes Using the Force.com Migration Tool and Git
Manage Org Changes Using the Force.com Migration Tool and GitManage Org Changes Using the Force.com Migration Tool and Git
Manage Org Changes Using the Force.com Migration Tool and Git
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
ePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version ControlePOM - Fundamentals of Research Software Development - Code Version Control
ePOM - Fundamentals of Research Software Development - Code Version Control
 
O365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van RousseltO365Con18 - Git and GitHub - Rick van Rousselt
O365Con18 - Git and GitHub - Rick van Rousselt
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git training v10
Git training v10Git training v10
Git training v10
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Git version control and trunk based approach with VSTS
Git version control and trunk based approach with VSTSGit version control and trunk based approach with VSTS
Git version control and trunk based approach with VSTS
 
3 Git
3 Git3 Git
3 Git
 

More from Moshe Kaplan

Web systems architecture, Performance and More
Web systems architecture, Performance and MoreWeb systems architecture, Performance and More
Web systems architecture, Performance and More
Moshe Kaplan
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
Moshe Kaplan
 

More from Moshe Kaplan (20)

Spark and C Integration
Spark and C IntegrationSpark and C Integration
Spark and C Integration
 
Introduction to Big Data
Introduction to Big DataIntroduction to Big Data
Introduction to Big Data
 
Introduciton to Python
Introduciton to PythonIntroduciton to Python
Introduciton to Python
 
Creating Big Data: Methodology
Creating Big Data: MethodologyCreating Big Data: Methodology
Creating Big Data: Methodology
 
Redis training for java software engineers
Redis training for java software engineersRedis training for java software engineers
Redis training for java software engineers
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineers
 
MongoDB from Basics to Scale
MongoDB from Basics to ScaleMongoDB from Basics to Scale
MongoDB from Basics to Scale
 
MongoDB Best Practices for Developers
MongoDB Best Practices for DevelopersMongoDB Best Practices for Developers
MongoDB Best Practices for Developers
 
The api economy
The api economyThe api economy
The api economy
 
Big Data Workshop
Big Data WorkshopBig Data Workshop
Big Data Workshop
 
Scale and Cloud Design Patterns
Scale and Cloud Design PatternsScale and Cloud Design Patterns
Scale and Cloud Design Patterns
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Web systems architecture, Performance and More
Web systems architecture, Performance and MoreWeb systems architecture, Performance and More
Web systems architecture, Performance and More
 
Do Big Data and NoSQL Fit Your Needs?
Do Big Data and NoSQL Fit Your Needs?Do Big Data and NoSQL Fit Your Needs?
Do Big Data and NoSQL Fit Your Needs?
 
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
The VP R&D Open Seminar on Project Management, SCRUM, Agile and Continuous De...
 
MySQL Multi Master Replication
MySQL Multi Master ReplicationMySQL Multi Master Replication
MySQL Multi Master Replication
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
 
Web Systems Architecture by Moshe Kaplan
Web Systems Architecture by Moshe KaplanWeb Systems Architecture by Moshe Kaplan
Web Systems Architecture by Moshe Kaplan
 
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuffBig Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
Big Data Seminar: Analytics, Hadoop, Map Reduce, Mongo and other great stuff
 
MySQL crash course by moshe kaplan
MySQL crash course by moshe kaplanMySQL crash course by moshe kaplan
MySQL crash course by moshe kaplan
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 

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