Page 1
Version control system: git
Madhu Belur
Control & Computing group,Electrical Engineering Dept, IIT Bombay
FOSSEE project, IIT BombayThis talk (updated/corrected) at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Dec 2017: Induction Training Programme
Belur/FOSSEE/Git Git version control 1/27
Page 2
Outline
Version control
Dropbox/Git/Google-Drive (GDrive)
Advantages/disadvantages of above 3 examples
Git commands
Spoken tutorials
Belur/FOSSEE/Git Git version control 2/27
Page 3
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 4
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 5
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 6
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 7
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 8
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 9
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 10
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 11
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 12
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 13
Version control
Why version control?
hard-disk crash! (actually very rare, these days)
delete file by mistake
overwrite by mistake
add/edit from the wrong past version
difficulty remembering which is the latest
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Belur/FOSSEE/Git Git version control 3/27
Page 14
Why version control: contd
Collaboration/sharing
Need for systematic file-naming (if multiple versions)
Need to revert back to a particular version (line-number,etc.)
Call past versions with short and long descriptions
extract differences about what changes weredone/resolved
Belur/FOSSEE/Git Git version control 4/27
Page 15
Why version control: contd
Collaboration/sharing
Need for systematic file-naming (if multiple versions)
Need to revert back to a particular version (line-number,etc.)
Call past versions with short and long descriptions
extract differences about what changes weredone/resolved
Belur/FOSSEE/Git Git version control 4/27
Page 16
Why version control: contd
Collaboration/sharing
Need for systematic file-naming (if multiple versions)
Need to revert back to a particular version (line-number,etc.)
Call past versions with short and long descriptions
extract differences about what changes weredone/resolved
Belur/FOSSEE/Git Git version control 4/27
Page 17
Why version control: contd
Collaboration/sharing
Need for systematic file-naming (if multiple versions)
Need to revert back to a particular version (line-number,etc.)
Call past versions with short and long descriptions
extract differences about what changes weredone/resolved
Belur/FOSSEE/Git Git version control 4/27
Page 18
Why version control: contd
Collaboration/sharing
Need for systematic file-naming (if multiple versions)
Need to revert back to a particular version (line-number,etc.)
Call past versions with short and long descriptions
extract differences about what changes weredone/resolved
Belur/FOSSEE/Git Git version control 4/27
Page 19
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 20
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 21
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 22
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 23
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 24
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 25
Git
Edit locally (using any plain text editor:Notepad/Emacs/Vim/Gedit/Pico/Nano). Your favoriteIDE: for Python, Latex, C, C++)
Available for GNU-Linux/Windows/Mac
Easy to install
Very useful for both local and online version control
Github: just an online repository: uses git commands
Bitbucket: also an online repository: uses git commands
Also, SVN and Mercurial (≡ hg) are good version controlsystems.
Belur/FOSSEE/Git Git version control 5/27
Page 26
Dropbox
Can edit locally
Need not be plain text
Can retrieve from internet
Auto-syncing (when internet is on)
Shows conflicts if somebody else updated before we‘pushed’ changes
Belur/FOSSEE/Git Git version control 6/27
Page 27
Dropbox
Can edit locally
Need not be plain text
Can retrieve from internet
Auto-syncing (when internet is on)
Shows conflicts if somebody else updated before we‘pushed’ changes
Belur/FOSSEE/Git Git version control 6/27
Page 28
Dropbox
Can edit locally
Need not be plain text
Can retrieve from internet
Auto-syncing (when internet is on)
Shows conflicts if somebody else updated before we‘pushed’ changes
Belur/FOSSEE/Git Git version control 6/27
Page 29
Dropbox
Can edit locally
Need not be plain text
Can retrieve from internet
Auto-syncing (when internet is on)
Shows conflicts if somebody else updated before we‘pushed’ changes
Belur/FOSSEE/Git Git version control 6/27
Page 30
Dropbox
Can edit locally
Need not be plain text
Can retrieve from internet
Auto-syncing (when internet is on)
Shows conflicts if somebody else updated before we‘pushed’ changes
Belur/FOSSEE/Git Git version control 6/27
Page 31
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 32
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 33
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 34
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 35
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 36
Google-drive
Need internet to edit/access
Need Gmail account
Not good for confidential information
Can edit directly on the drive (doc/spreadsheet/ppt)
Can see the collaborator’s cursor
Automatically no ‘conflicts’
Each small edit is a separate version: too many versions
Belur/FOSSEE/Git Git version control 7/27
Page 37
Summary and broad purposes
Git: for simple to very complex coding: advancedfeatures for this
Dropbox: for any type of file: automatic syncing
GDrive: no local editing. Only directly on Internet
Belur/FOSSEE/Git Git version control 8/27
Page 38
Summary and broad purposes
Git: for simple to very complex coding: advancedfeatures for this
Dropbox: for any type of file: automatic syncing
GDrive: no local editing. Only directly on Internet
Belur/FOSSEE/Git Git version control 8/27
Page 39
Summary and broad purposes
Git: for simple to very complex coding: advancedfeatures for this
Dropbox: for any type of file: automatic syncing
GDrive: no local editing. Only directly on Internet
Belur/FOSSEE/Git Git version control 8/27
Page 40
Some comparisons
Favorite editor: sayemacs/vim/gedit/notepad/wordpad/nano
Git: any editor
Dropbox: any editor
GDrive: (at least default): forced to use very-basiceditor
Belur/FOSSEE/Git Git version control 9/27
Page 41
Some comparisons
Favorite editor: sayemacs/vim/gedit/notepad/wordpad/nano
Git: any editor
Dropbox: any editor
GDrive: (at least default): forced to use very-basiceditor
Belur/FOSSEE/Git Git version control 9/27
Page 42
Some comparisons
Favorite editor: sayemacs/vim/gedit/notepad/wordpad/nano
Git: any editor
Dropbox: any editor
GDrive: (at least default): forced to use very-basiceditor
Belur/FOSSEE/Git Git version control 9/27
Page 43
Some comparisons
Favorite editor: sayemacs/vim/gedit/notepad/wordpad/nano
Git: any editor
Dropbox: any editor
GDrive: (at least default): forced to use very-basiceditor
Belur/FOSSEE/Git Git version control 9/27
Page 44
Some comparisons
Favorite editor: sayemacs/vim/gedit/notepad/wordpad/nano
Git: any editor
Dropbox: any editor
GDrive: (at least default): forced to use very-basiceditor
Belur/FOSSEE/Git Git version control 9/27
Page 45
Conflict resolution (collaboration)
Git: shows pin-pointed differences, and shortcuts forresolving
Dropbox: reasonably (I believe)
GDrive: shows with colour about changes
Belur/FOSSEE/Git Git version control 10/27
Page 46
Conflict resolution (collaboration)
Git: shows pin-pointed differences, and shortcuts forresolving
Dropbox: reasonably (I believe)
GDrive: shows with colour about changes
Belur/FOSSEE/Git Git version control 10/27
Page 47
Conflict resolution (collaboration)
Git: shows pin-pointed differences, and shortcuts forresolving
Dropbox: reasonably (I believe)
GDrive: shows with colour about changes
Belur/FOSSEE/Git Git version control 10/27
Page 48
Conflict resolution (collaboration)
Git: shows pin-pointed differences, and shortcuts forresolving
Dropbox: reasonably (I believe)
GDrive: shows with colour about changes
Belur/FOSSEE/Git Git version control 10/27
Page 49
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 50
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 51
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 52
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 53
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 54
Automatic syncing
Git: manual syncing: recommended for complex code(with shortcuts)Ensure no bugs before ‘committing’ changes or lettingothers see
Others (Dropbox/GDrive) automatic: and can beirritating or advantageous
Each local small change keeps syncing: bad for latex andcollaborators, etc.
GDrive: nothing local anyway
Belur/FOSSEE/Git Git version control 11/27
Page 55
Online repository
GDrive: only online repository
Local repo possible for Dropbox and Git
Online repository: relevant for sharing or multiple PCsfor oneself
Belur/FOSSEE/Git Git version control 12/27
Page 56
Online repository
GDrive: only online repository
Local repo possible for Dropbox and Git
Online repository: relevant for sharing or multiple PCsfor oneself
Belur/FOSSEE/Git Git version control 12/27
Page 57
Online repository
GDrive: only online repository
Local repo possible for Dropbox and Git
Online repository: relevant for sharing or multiple PCsfor oneself
Belur/FOSSEE/Git Git version control 12/27
Page 58
Online repository
GDrive: only online repository
Local repo possible for Dropbox and Git
Online repository: relevant for sharing or multiple PCsfor oneself
Belur/FOSSEE/Git Git version control 12/27
Page 59
Branching
Relevant for code: when packages provide support formultiple versions
Git: targets such purposes: internationally used byindividuals and companies
Dropbox/GDrive: need to just make copies. No‘merging’
Belur/FOSSEE/Git Git version control 13/27
Page 60
Branching
Relevant for code: when packages provide support formultiple versions
Git: targets such purposes: internationally used byindividuals and companies
Dropbox/GDrive: need to just make copies. No‘merging’
Belur/FOSSEE/Git Git version control 13/27
Page 61
Branching
Relevant for code: when packages provide support formultiple versions
Git: targets such purposes: internationally used byindividuals and companies
Dropbox/GDrive: need to just make copies. No‘merging’
Belur/FOSSEE/Git Git version control 13/27
Page 62
Branching
Relevant for code: when packages provide support formultiple versions
Git: targets such purposes: internationally used byindividuals and companies
Dropbox/GDrive: need to just make copies. No‘merging’
Belur/FOSSEE/Git Git version control 13/27
Page 63
Sharing
Github and bitbucket: some free/paid privaterepositories
Public repositories (meaning anybody can VIEW, butedit-access for few only.)
Dropbox/GDrive: can share to specificemail-addresses/accounts (any number)
GDrive allows: view/edit: but also ‘commenting’(intermediate level access)
Belur/FOSSEE/Git Git version control 14/27
Page 64
Sharing
Github and bitbucket: some free/paid privaterepositories
Public repositories (meaning anybody can VIEW, butedit-access for few only.)
Dropbox/GDrive: can share to specificemail-addresses/accounts (any number)
GDrive allows: view/edit: but also ‘commenting’(intermediate level access)
Belur/FOSSEE/Git Git version control 14/27
Page 65
Sharing
Github and bitbucket: some free/paid privaterepositories
Public repositories (meaning anybody can VIEW, butedit-access for few only.)
Dropbox/GDrive: can share to specificemail-addresses/accounts (any number)
GDrive allows: view/edit: but also ‘commenting’(intermediate level access)
Belur/FOSSEE/Git Git version control 14/27
Page 66
Sharing
Github and bitbucket: some free/paid privaterepositories
Public repositories (meaning anybody can VIEW, butedit-access for few only.)
Dropbox/GDrive: can share to specificemail-addresses/accounts (any number)
GDrive allows: view/edit: but also ‘commenting’(intermediate level access)
Belur/FOSSEE/Git Git version control 14/27
Page 67
Sharing
Github and bitbucket: some free/paid privaterepositories
Public repositories (meaning anybody can VIEW, butedit-access for few only.)
Dropbox/GDrive: can share to specificemail-addresses/accounts (any number)
GDrive allows: view/edit: but also ‘commenting’(intermediate level access)
Belur/FOSSEE/Git Git version control 14/27
Page 68
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 69
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 70
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 71
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 72
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 73
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 74
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 75
Git and Github
Why Git?
Very relevant for code
Internationally the norm: only ‘laymen’ shy away fromgit/github
Advanced features: fork (edit independently andperhaps merge)
Ask owner for ‘pull request’ to merge our fork back
For alpha/beta versions of new packages
Github shows full code history: allows automatic testing(nose-tests, test driven development)
Belur/FOSSEE/Git Git version control 15/27
Page 76
Installation: for MS Windows
Google for git MS-windows setup file
Open MS command prompt and make a suitabledirectory for testing purposes
md and cd are MD-DOS commands for making adirectory and changing into that directory
Belur/FOSSEE/Git Git version control 16/27
Page 77
Installation: for Ubuntu GNU-Linux
sudo apt-get install git
Belur/FOSSEE/Git Git version control 17/27
Page 78
Git commands
git config --global user.name "Madhu Belur"
git config --global user.email [email protected]
(without ‘–global’ flag: only for that directory)
git init
git add filename
Belur/FOSSEE/Git Git version control 18/27
Page 79
Git commands
git config --global user.name "Madhu Belur"
git config --global user.email [email protected]
(without ‘–global’ flag: only for that directory)
git init
git add filename
Belur/FOSSEE/Git Git version control 18/27
Page 80
Git commands
git config --global user.name "Madhu Belur"
git config --global user.email [email protected]
(without ‘–global’ flag: only for that directory)
git init
git add filename
Belur/FOSSEE/Git Git version control 18/27
Page 81
Make changes and then commit
git commit
git diff
git revert # to the version you want
In bash, # means everything after # is ‘comment’ (onthat line: ignore)
Many spoken-tutorials available athttp://spoken-tutorial.org
Belur/FOSSEE/Git Git version control 19/27
Page 82
Make changes and then commit
git commit
git diff
git revert # to the version you want
In bash, # means everything after # is ‘comment’ (onthat line: ignore)
Many spoken-tutorials available athttp://spoken-tutorial.org
Belur/FOSSEE/Git Git version control 19/27
Page 83
Make changes and then commit
git commit
git diff
git revert # to the version you want
In bash, # means everything after # is ‘comment’ (onthat line: ignore)
Many spoken-tutorials available athttp://spoken-tutorial.org
Belur/FOSSEE/Git Git version control 19/27
Page 84
Make changes and then commit
git commit
git diff
git revert # to the version you want
In bash, # means everything after # is ‘comment’ (onthat line: ignore)
Many spoken-tutorials available athttp://spoken-tutorial.org
Belur/FOSSEE/Git Git version control 19/27
Page 85
Editor changing (during committing)
How to change editor
git config --global core.editor notepad # (for MSWindows)
git config --global core.editor nano # (for linux, etc)
git config --global core.editor emacs # (for linux, etc)
https://help.github.com/articles/associating-text-editors-with-git
https://help.github.com/articles/associating-text-editors-with-
git/#platform-windows
Belur/FOSSEE/Git Git version control 20/27
Page 86
How to delete a file
First delete the file the regular way
Tell git you are no longer interested in the file bygit rm filename
git commit # tell as comment that you deleted the file(intentionally)
Belur/FOSSEE/Git Git version control 21/27
Page 87
How to retrieve deleted file
If file was never committed to git, then git cannot help:-)
If file was committed at least once, and then we retrievethe deleted (and commited) file by:git checkout HEADˆ filename
This will retrieve the version just before deleting
Need to commit again (to tell git about the latestversion: post un-deleting the file)
Can retrieve previously committed versions also (usingrevert)
https://stackoverflow.com/questions/953481/find-and-
restore-a-deleted-file-in-a-git-repository
Belur/FOSSEE/Git Git version control 22/27
Page 88
How to revert
Need to understand small but complex differencebetween
staging areacheckoutHEADMASTER Branch
HEAD means current (latest committed)
HEAD 1 means just previously committed one (HEADminus 1)
git log file or git log
gives log (with your descriptions)
Belur/FOSSEE/Git Git version control 23/27
Page 89
How to see differences
git diff filename
shows difference between just-previously committed oneand latest
Belur/FOSSEE/Git Git version control 24/27
Page 90
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 91
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 92
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 93
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 94
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 95
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 96
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 97
Github for collaboration
git clone # optional (for taking previous repo)
git add
change, commit, ‘push’ # push also optional
Or request for pulling our changes
pull-request: the owner pulls our changes, so we requesthim/her to pull our changes
git from browser allows interactive displays: shows conflictswith syntax highlighting
Belur/FOSSEE/Git Git version control 25/27
Page 98
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 99
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 100
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 101
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 102
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 103
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 104
Version control as a habit
Learn to keep past versions ‘systematically’
final.doc, final1.doc, finalest.doc, most-final.doc,final8thDec.doc,final8thDec.doc (but last-edited on 13thDec)final8thDecWithAdditions.doc
Relevant for retrieving: recommended forlocal/individual usage also
Belur/FOSSEE/Git Git version control 26/27
Page 105
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 106
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 107
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 108
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 109
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 110
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 111
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 112
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27
Page 113
Overhead
Tell git explicitly to maintain only ‘source’ (and not‘generated’ files)
Extra past source-files saved: extra disk-usage: overhead
Negligible overhead (of saving past versions)
Can quickly search through comments of past versions
Internet bandwidth: always will be inadequate: videocalls, HD-movies
Safer/wiser to be independent of Internet
Latest version of this ppt at:
http://www.ee.iitb.ac.in/%7Ebelur/talks/
Thank you
Belur/FOSSEE/Git Git version control 27/27