SlideShare a Scribd company logo
What is Git?
Distributed version control system
Linus Torvalds - to track linux kernel development
Free and open source
Designed to handle small/large projects with speed and
efficiency
Fast branching and merging
Distributed vs Centralized
Basic git workflow
Initializing a git repo
# got some code in directory
$ git init [--bare]
# or clone
$ git clone --depth 1 –b <branch>
$ git clone /var/www/code.git
Then push to remote with upstream set for tracking
$ git push –u origin <master>
Example of gitignore
$ cat .gitignore
*.[oa]
*~ # ending with ~
*.a # no .a files
!lib.a # but do track lib.a, even though you're ignoring .a files above
/TODO # only ignore the root TODO file, not subdir/TODO
build/ # ignore all files in the build/ directory
doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt
Doc/**/*.txt # all nested .txt files
Viewing staged and unstaged changes
• git status
• git diff (Compares working directory with staging area)
• git diff --staged
• git diff HEAD
• git diff v1.0 v1.1
• git diff master adposting
Branching
Branching
Creating new branch
$ git branch testing
$ git checkout testing
Basic branching and merging
$ git checkout iss53
Switched to branch "iss53"
$ vim index.html
$ git commit -a -m 'finished the new footer [issue 53]'
[iss53]: created ad82d7a: "finished the new footer [issue 53]"
1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout master
$ git merge iss53
Merge made by recursive.
README | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Merging and Rebase
# Merging leaves short-term branch intact but rebase makes it non-divergent
$ git checkout experiment
$ git rebase master
First, rewinding head to replay your work on top of it... Applying: added staged
command
Branch management
$ git branch # Shows all the active branches
$ git branch -v # Shows last commit on each branch
$ git branch --merged # Shows which branches are merged with the branch you are on
$ git branch --no-merged # Shows all branches that contain work you haven’t merged
$ git branch -d testing # To delete a branch. Will fail if the branch is not yet merged
Remote branches
# Branches are just reference
# as many branch as you may as remote
$ git fetch origin # Fetches any data you don’t have from remote ‘origin’ repository
$ git pull origin # Fetches any data you don’t have and merges it with local branch
$ git fetch origin master # Fetches data only from ‘master’ branch
$ git pull origin master # Fetches data from master and merges it with local master branch
git fetch origin
$ git push origin develop # Pushes data from local ‘develop’ branch to remote ‘develop’ branch
$ git push origin develop:release # Pushes data from local ‘develop’ branch to remote ‘release’ branch
Tagging and release
$ git tag -a v1.0.1 # applies v1.0.1 tag to current commit
$ git tag # To list all tags
$ git tag -1 ‘v1.4.2*‘ # List all tags starting with 1.4.2
$ git tag -a v1.0.1 -m ‘my version 1.0.1’
$ git show v1.4
tag v1.4
Tagger: Scott Chacon <schacon@gee-mail.com>
Date: Mon Feb 9 14:45:11 2009 -0800
my version 1.4
commit 15027957951b64cf874c3557a0f3547bd83b3ff6
Merge: 4a447f7... a6b4c97...
Author: Scott Chacon <schacon@gee-mail.com>
Date: Sun Feb 8 19:02:46 2009 -0800
Merge branch 'experiment'
Tagging
$ git log --pretty=oneline
15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
Tar Later:
$ git tag -a v1.2 9fceb02
Git remote server
# HTTP and smart HTTP
# SSH and GIT protocol
Git config
$ git config --global core.editor emacs
$ git config --global user.name "John Doe"
$ git config --global user.eail johndoe@example.com
Has override like /etc/gitconfig -> ~/.gitconfig -> /.git/config
$ git config --global commit.template ~/.gitmessage.txt
Git attributes
.gitattributes
*.pbcpropj binary
*.docs diff=word
*.png diff=exif
*.pbxproj binary
Hooks
# to streamline workflows
# client side hook
# server-side hook
Bundling and archiving
# bundle to transfer git repo
# archive to provide just the files

More Related Content

KEY
Git Basics at Rails Underground
PDF
Git: basic to advanced
PDF
Git - Get Ready To Use It
ODP
The Fundamentals of Git
PPT
Learn Git Basics
PDF
Git Real
PDF
GIT - GOOD PRACTICES
PDF
Git Basics at Rails Underground
Git: basic to advanced
Git - Get Ready To Use It
The Fundamentals of Git
Learn Git Basics
Git Real
GIT - GOOD PRACTICES

What's hot (20)

PDF
Loading...git
PPTX
Get Good With Git
PPTX
Intro to Git DevOps Tally Presentation 101615
PPTX
Git for beginner
PDF
Undoing Things in Git
KEY
Git Basics - RubyFest 2009
PDF
Version Control with Git for Beginners
KEY
Basic Git
PDF
Git real slides
PPTX
Git basic
PDF
DOCX
Git github
PPTX
Understanding about git
PDF
Git Basics (Professionals)
PDF
Integrate gitolite with mantis
PPTX
Git beyond basics
KEY
Git Magic: Versioning Files like a Boss
PPTX
Lets Git Together
PDF
Git introduction
PDF
GIT: Content-addressable filesystem and Version Control System
Loading...git
Get Good With Git
Intro to Git DevOps Tally Presentation 101615
Git for beginner
Undoing Things in Git
Git Basics - RubyFest 2009
Version Control with Git for Beginners
Basic Git
Git real slides
Git basic
Git github
Understanding about git
Git Basics (Professionals)
Integrate gitolite with mantis
Git beyond basics
Git Magic: Versioning Files like a Boss
Lets Git Together
Git introduction
GIT: Content-addressable filesystem and Version Control System
Ad

Similar to Get going with_git_ppt (20)

PDF
Git basics
PDF
Did you git yet?
PDF
Git the Docs: A fun, hands-on introduction to version control
PDF
Git training
PPT
Git presentation
PDF
Getting some Git
KEY
Git Tech Talk
PPTX
Learning Basic GIT Cmd
PDF
Git and github 101
PDF
Pro git - grasping it conceptually
PDF
Introduction to Git for Artists
PDF
Git cheat-sheet
PDF
Git cheat-sheet 2021
PDF
GIT Basics
PDF
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
PDF
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
PDF
Git Concepts, Commands and Connectivity
PPTX
Git basics
Did you git yet?
Git the Docs: A fun, hands-on introduction to version control
Git training
Git presentation
Getting some Git
Git Tech Talk
Learning Basic GIT Cmd
Git and github 101
Pro git - grasping it conceptually
Introduction to Git for Artists
Git cheat-sheet
Git cheat-sheet 2021
GIT Basics
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Git Concepts, Commands and Connectivity
Ad

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Understanding_Digital_Forensics_Presentation.pptx
Spectroscopy.pptx food analysis technology
The AUB Centre for AI in Media Proposal.docx
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25 Week I
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing

Get going with_git_ppt

  • 1. What is Git? Distributed version control system Linus Torvalds - to track linux kernel development Free and open source Designed to handle small/large projects with speed and efficiency Fast branching and merging
  • 4. Initializing a git repo # got some code in directory $ git init [--bare] # or clone $ git clone --depth 1 –b <branch> $ git clone /var/www/code.git Then push to remote with upstream set for tracking $ git push –u origin <master>
  • 5. Example of gitignore $ cat .gitignore *.[oa] *~ # ending with ~ *.a # no .a files !lib.a # but do track lib.a, even though you're ignoring .a files above /TODO # only ignore the root TODO file, not subdir/TODO build/ # ignore all files in the build/ directory doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt Doc/**/*.txt # all nested .txt files
  • 6. Viewing staged and unstaged changes • git status • git diff (Compares working directory with staging area) • git diff --staged • git diff HEAD • git diff v1.0 v1.1 • git diff master adposting
  • 9. Creating new branch $ git branch testing $ git checkout testing
  • 10. Basic branching and merging $ git checkout iss53 Switched to branch "iss53" $ vim index.html $ git commit -a -m 'finished the new footer [issue 53]' [iss53]: created ad82d7a: "finished the new footer [issue 53]" 1 files changed, 1 insertions(+), 0 deletions(-) $ git checkout master $ git merge iss53 Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
  • 11. Merging and Rebase # Merging leaves short-term branch intact but rebase makes it non-divergent $ git checkout experiment $ git rebase master First, rewinding head to replay your work on top of it... Applying: added staged command
  • 12. Branch management $ git branch # Shows all the active branches $ git branch -v # Shows last commit on each branch $ git branch --merged # Shows which branches are merged with the branch you are on $ git branch --no-merged # Shows all branches that contain work you haven’t merged $ git branch -d testing # To delete a branch. Will fail if the branch is not yet merged
  • 13. Remote branches # Branches are just reference # as many branch as you may as remote $ git fetch origin # Fetches any data you don’t have from remote ‘origin’ repository $ git pull origin # Fetches any data you don’t have and merges it with local branch $ git fetch origin master # Fetches data only from ‘master’ branch $ git pull origin master # Fetches data from master and merges it with local master branch git fetch origin $ git push origin develop # Pushes data from local ‘develop’ branch to remote ‘develop’ branch $ git push origin develop:release # Pushes data from local ‘develop’ branch to remote ‘release’ branch
  • 14. Tagging and release $ git tag -a v1.0.1 # applies v1.0.1 tag to current commit $ git tag # To list all tags $ git tag -1 ‘v1.4.2*‘ # List all tags starting with 1.4.2 $ git tag -a v1.0.1 -m ‘my version 1.0.1’ $ git show v1.4 tag v1.4 Tagger: Scott Chacon <schacon@gee-mail.com> Date: Mon Feb 9 14:45:11 2009 -0800 my version 1.4 commit 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge: 4a447f7... a6b4c97... Author: Scott Chacon <schacon@gee-mail.com> Date: Sun Feb 8 19:02:46 2009 -0800 Merge branch 'experiment'
  • 15. Tagging $ git log --pretty=oneline 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment' a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support 0d52aaab4479697da7686c15f77a3d64d9165190 one more thing Tar Later: $ git tag -a v1.2 9fceb02
  • 16. Git remote server # HTTP and smart HTTP # SSH and GIT protocol
  • 17. Git config $ git config --global core.editor emacs $ git config --global user.name "John Doe" $ git config --global user.eail johndoe@example.com Has override like /etc/gitconfig -> ~/.gitconfig -> /.git/config $ git config --global commit.template ~/.gitmessage.txt
  • 18. Git attributes .gitattributes *.pbcpropj binary *.docs diff=word *.png diff=exif *.pbxproj binary
  • 19. Hooks # to streamline workflows # client side hook # server-side hook
  • 20. Bundling and archiving # bundle to transfer git repo # archive to provide just the files