SlideShare a Scribd company logo
WORKING WITH GIT
Praveen Chamarthi / @praveenc
INSTALLING GIT
http://git-scm.com/downloads
GLOBAL CONFIGURATION
Mandatory
$ git config ­­global user.username "praveenc"
$ git config ­­global user.name "Praveen C"
$ git config ­­global user.email "praveenc@netmail.com"
Optional, but good to have
$ git config ­­global core.editor "vim"
$ git config ­­global core.autocrlf "false"
$ git config ­­global color.ui "auto"
$ git config ­­global color.diff "auto"
$ git config ­­global color.branch "auto"
$ git config ­­global color.interactive "auto"
GIT ALIASES
Most common
$ git config ­­global alias.co checkout
$ git config ­­global alias.br branch
$ git config ­­global alias.ci commit
$ git config ­­global alias.st status
$ git config ­­global alias.unstage 'reset HEAD ­­'
$ git config ­­global alias.last 'log ­1 HEAD'
E.g.
$ git co development
Switched to branch 'development'
External commands
$ git config ­­global alias.visual "!gitk"
CLONING REPOSITORIES
git clone [url]:reponame
E.g.
$ git clone git@mygitserver.com:platform.git
Cloning into 'platform'...
remote: Counting objects: ..., done.
remote: Compressing objects: ..., done.
remote: Total ..., reused ... (delta ...)
Receiving objects: 100% (...), 42.25 MiB | 15.57 MiB/s, done
Resolving deltas: 100% (...), done.
Checking connectivity... done.
Checking out files: 100% (...), done.
VERIFYING REMOTES (SOURCE)
View remote props
$ git remote ­v
origin  git@mygitserver.com:platform (fetch)
origin  git@mygitserver.com:platform (push)
$ git remote show origin
* remote origin
  Fetch URL: git@mygitserver.com:platform
  Push  URL: git@mygitserver.com:platform
  HEAD branch: master
  Remote branches:
    development tracked
    master      tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
CHECKOUT REMOTE BRANCH
View remote branches
$ git branch ­r
  origin/HEAD ­> origin/master
  origin/development
  origin/master
Check-out remote branch 'development'
$ git branch
* master
$ git checkout development
Switched to a new branch 'development'
$ git branch
* development
  master
$ git status
on branch development
nothing to commit, working directory clean
GIT COMMIT WORKFLOW
ADD FILES TO STAGING AREA
Adding files
$ git add .
$ git add ­A
$ git add ­­all
$ git add js/*.js
$ git add *.txt
Diff
$ git diff
$ git diff ­­staged
COMMITTING CHANGES
Committing a staged change
$ git commit ­m "Added readme.txt"
Add to staging and commit
$ git commit ­a ­m "Added readme.txt"
MANAGING CHANGES
Unstaging changes
$ git reset HEAD [filename]
Unmodifying a modified file
$ git checkout ­­ [filename]
** WARNING: You'll lose all changes (un-recoverable) **
Amending commits
$ git commit ­m "NM­0000 fixed something"
$ git add forgotten_file
$ git commit ­­amend
VIEW COMMIT HISTORY
default log view
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Praveen Chamarthi [praveenc@netmail.com]
Date:   Tue Mar 12 21:52:11 2015 ­0700
    changed the version number
detailed log
$ git log ­p ­1
commit a4ef8f2c37c0408b7c69f66f95c796ea64e4bbaf
Author: debug [debug@netmail.com]
Date:   Wed May 13 13:36:11 2015 ­0400
    added readme.txt
diff ­­git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..709087a
­­­ /dev/null
+++ b/readme.txt
@@ ­0,0 +1 @@
+thiasdfkajsdfadfl;asdfa
SYNC CHANGES WITH SERVER
Push & Pull
$ git push (push to remote repo)
$ git fetch (fetch only, no merge)
$ git pull (git fetch + git merge)
git pull = git fetch + git merge
GIT BRANCHING
Checkout a remote branch
View remote branches
$ git branch ­r
  origin/HEAD ­> origin/master
  origin/development
  origin/master
Checkout remote branch
$ git checkout [branchname]
E.g.
$ git checkout development
GIT BRANCHING
Working with local branches
$ git checkout development
$ git branch
* development
  master
create local branch using -b flag
$ git checkout ­b NM­3435
Switched to a new branch 'NM­3435'
$ git branch
* NM­3435
  development
  master
GIT BRANCHING
Merging local branch to upstream branch
$ git checkout development
Switched to branch 'development'
$ git pull
Updating development
Fast­forward
$ git merge NM­3435
Updating 9e11133..a4ef8f2
Fast­forward
 readme.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 readme.txt
Deleting a local branch
$ git branch ­d NM­3435
Deleted branch NM­3435 (was a4ef8f2).
GIT TAGS
List tags
$ git tag ­l
5.4.0.550
5.4.0.541
$ git tag ­l '5.4.0*'
Create Tags
$ git tag 5.4.0_HP2 (lightweight tag)
$ git tag ­a 5.4.0_HP2 ­m "5.4.0 HP2 ­ performance improvements"
Sharing Tags
$ git push ­­tags (push all tags)
$ git push origin 5.4.0_HP2 (push specific tags)
GIT TAGS
Checking out a Tag
$ git checkout tags/5.4.0_HP2
$ git branch ­a
* (detached from 5.4.0_HP2)
  master
  remotes/origin/HEAD ­> origin/master
  remotes/origin/develop
  remotes/origin/master
$ git checkout ­b HP2_Fix
Switched to new branch 'HP2_Fix'
Q & A
praveenc@netmail.com
Git, A Primer

More Related Content

What's hot

Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
Kanstantsin Shautsou
 
Git branching model_for_tap_team
Git branching model_for_tap_teamGit branching model_for_tap_team
Git branching model_for_tap_teamGrzegorz Wilczynski
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
Eneldo Serrata
 
Pioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with PlonePioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with Plone
Clayton Parker
 
Git
GitGit
Git rerere
Git rerereGit rerere
Git rerereSean Lee
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
Federico Panini
 

What's hot (9)

Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
 
Git branching model_for_tap_team
Git branching model_for_tap_teamGit branching model_for_tap_team
Git branching model_for_tap_team
 
About GIT
About GITAbout GIT
About GIT
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
 
Pioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with PlonePioneer a Strategic Change in Content Organization with Plone
Pioneer a Strategic Change in Content Organization with Plone
 
Git
GitGit
Git
 
Git rerere
Git rerereGit rerere
Git rerere
 
Git in pills : git stash
Git in pills : git stashGit in pills : git stash
Git in pills : git stash
 
Gittalk
GittalkGittalk
Gittalk
 

Viewers also liked

Instruccincvica 090605012524-phpapp01
Instruccincvica 090605012524-phpapp01Instruccincvica 090605012524-phpapp01
Instruccincvica 090605012524-phpapp01
Rocio Villalba
 
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
Rolin Moe
 
Comparison of symmetrical and asymmetrical cascaded current source multilevel...
Comparison of symmetrical and asymmetrical cascaded current source multilevel...Comparison of symmetrical and asymmetrical cascaded current source multilevel...
Comparison of symmetrical and asymmetrical cascaded current source multilevel...
eSAT Journals
 
Erkenning van qEEG onderzoek door het RIZIV
Erkenning van qEEG onderzoek door het RIZIVErkenning van qEEG onderzoek door het RIZIV
Metodos de optimizacion
Metodos de optimizacionMetodos de optimizacion
Metodos de optimizacion
luisatero
 
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...Laszlo Szoboszlai
 
Alat fertilisasi simulasi
Alat fertilisasi simulasiAlat fertilisasi simulasi
Alat fertilisasi simulasi
Herfen Suryati
 
Resume
ResumeResume
Resumeraa874
 
Alat peraga perbedaan sifat zat padat, cair dan gas sederhana
Alat peraga perbedaan sifat zat padat, cair dan gas sederhanaAlat peraga perbedaan sifat zat padat, cair dan gas sederhana
Alat peraga perbedaan sifat zat padat, cair dan gas sederhana
Herfen Suryati
 
Optimizacion
OptimizacionOptimizacion
Optimizacion
luisatero
 
La amistad
La amistadLa amistad
Portadas nacionales 15 febrero-17
Portadas nacionales 15 febrero-17Portadas nacionales 15 febrero-17
Portadas nacionales 15 febrero-17
Portadas Nacionales Think Mercadotecnia
 

Viewers also liked (13)

Instruccincvica 090605012524-phpapp01
Instruccincvica 090605012524-phpapp01Instruccincvica 090605012524-phpapp01
Instruccincvica 090605012524-phpapp01
 
Wonder profile - final
Wonder profile - finalWonder profile - final
Wonder profile - final
 
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
The Sale of 'Open Content' - Recognizing & Negotiating the Philosophical Quan...
 
Comparison of symmetrical and asymmetrical cascaded current source multilevel...
Comparison of symmetrical and asymmetrical cascaded current source multilevel...Comparison of symmetrical and asymmetrical cascaded current source multilevel...
Comparison of symmetrical and asymmetrical cascaded current source multilevel...
 
Erkenning van qEEG onderzoek door het RIZIV
Erkenning van qEEG onderzoek door het RIZIVErkenning van qEEG onderzoek door het RIZIV
Erkenning van qEEG onderzoek door het RIZIV
 
Metodos de optimizacion
Metodos de optimizacionMetodos de optimizacion
Metodos de optimizacion
 
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...
Szoboszlai_Laszlo_VERNACULAR BUILDING DESIGN STRATEGIES FOR MODERN SUSTAINABL...
 
Alat fertilisasi simulasi
Alat fertilisasi simulasiAlat fertilisasi simulasi
Alat fertilisasi simulasi
 
Resume
ResumeResume
Resume
 
Alat peraga perbedaan sifat zat padat, cair dan gas sederhana
Alat peraga perbedaan sifat zat padat, cair dan gas sederhanaAlat peraga perbedaan sifat zat padat, cair dan gas sederhana
Alat peraga perbedaan sifat zat padat, cair dan gas sederhana
 
Optimizacion
OptimizacionOptimizacion
Optimizacion
 
La amistad
La amistadLa amistad
La amistad
 
Portadas nacionales 15 febrero-17
Portadas nacionales 15 febrero-17Portadas nacionales 15 febrero-17
Portadas nacionales 15 febrero-17
 

Similar to Git, A Primer

GIT 101
GIT 101GIT 101
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Mahmoud Said
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Essential git fu for tech writers
Essential git fu for tech writersEssential git fu for tech writers
Essential git fu for tech writers
Gaurav Nelson
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
E Carter
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
Atlassian
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
Nicola Paolucci
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
Forest Mars
 
Version control
Version controlVersion control
Version control
Rajesh Khadka
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
Chia Wei Tsai
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
Dmitry Sheiko
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
Hoffman Lab
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
Paulo Henrique Nonaka
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
James Gray
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git
GitGit
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Arpit Mohan
 

Similar to Git, A Primer (20)

GIT 101
GIT 101GIT 101
GIT 101
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Git
GitGit
Git
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Hello git
Hello git Hello git
Hello git
 
Essential git fu for tech writers
Essential git fu for tech writersEssential git fu for tech writers
Essential git fu for tech writers
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Version control
Version controlVersion control
Version control
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git
GitGit
Git
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 

Git, A Primer