Intro to GIT
Gharpay – Friday 3/08/2012
Arpit Mohan
Version Control?
Why?
How?
Ctrl-C + Ctrl-V ( Most popular )
Centralized VCS ( Version Control System ) Eg.
SVN, Perforce.
...
Salient Features of Git
Distributed VCS. Each system is a complete
mirror of the repository.

Data integrity. All data is ...
Install GIT

You already know this! Else, try out the awesome
website a few friends, Sergey Brin and Larry
Page built – ht...
Git Configuration
Identity – Very very important. It helps us identify who you are and
what you did. Associated tools like...
Few Git Paradigms
Working
Directory

Staging
Area

Git
Repository
(Local)

Git
Repository
(Remote)

• Distributed System. ...
Git Commands
$ git status
$ git branch (To name the branch)
$ git add <filename> (To begin tracking a new file or stage a
...
Git Logs (contd)
$ git log –pretty=oneline (Pretty print the log)
$ git log --pretty=format:"%h - %an, %ar : %s”
$ git log...
Amending the Tree
$ git commit –amend
Example:
$ git commit -m ’initial commit’
$ git add forgotten_file
$ git commit –ame...
Remote Repository
$ git remote –v ( Name and URL of the remote
server)

$ git remote add <branch> <url of remote repo>
$ g...
Git Branches
Git branches are one of the most potent features
of Git. Learn it and it may just change your life!

$ git br...
Merging & Rebasing
$ git merge <branchname> ( Merging another
branch into this )

$ git rebase [basebranch] [topicbranch](...
Interesting Features
$ git bisect start
$ git bisect good
$ git bisect bad
$ git bisect reset
$ git bisect run testing.sh
...
Interesting Features
Hooks (Server side and Client side)
Pre-commit hooks
Post-commit hooks

$ git gc
Upcoming SlideShare
Loading in …5
×

Introduction to GIT

482 views

Published on

This presentation is an introduction to GIT and contains a list of some of the cool features that a VCS can provde.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
482
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to GIT

  1. 1. Intro to GIT Gharpay – Friday 3/08/2012 Arpit Mohan
  2. 2. Version Control? Why? How? Ctrl-C + Ctrl-V ( Most popular ) Centralized VCS ( Version Control System ) Eg. SVN, Perforce. Distributed VCS. Eg. Git, Mercurial When?
  3. 3. Salient Features of Git Distributed VCS. Each system is a complete mirror of the repository. Data integrity. All data is check-summed and stored as the SHA1-ID. Differential data. Capability to do-undo changes without fear of data corruption.
  4. 4. Install GIT You already know this! Else, try out the awesome website a few friends, Sergey Brin and Larry Page built – http://www.google.com 
  5. 5. Git Configuration Identity – Very very important. It helps us identify who you are and what you did. Associated tools like Jenkins, CruiseControl etc use this identity to perform more functions. $ git config --global user.name ”Arpit Mohan” $ git config --global user.email arpit@gharpay.in $ git config --global core.editor emacs (By default Vi/Vim) $ git config --global merge.tool vimdiff ( I use Eclipse  ) $ git config –list $ git help <action> - Some old methods never die! $ git config --global alias.co checkout (You can setup multiple aliases) All this is stored in ~/.gitconfig file. Check it out.
  6. 6. Few Git Paradigms Working Directory Staging Area Git Repository (Local) Git Repository (Remote) • Distributed System. Every checkout is a snapshot. No loss of data. Multiple copies. • Primarily local operations. Very little interaction with remote repository. Hence faster! Untracked Unmodified Modified Staged Committed Pushed
  7. 7. Git Commands $ git status $ git branch (To name the branch) $ git add <filename> (To begin tracking a new file or stage a file for commit) $ vi .gitignore (Get Git to ignore files. Eg. Log files) $ git commit –m “<Commit Message>” <filenames> (-a) $ git rm <filename> Removes the file from local and repo. $ git rm --cached <filename> $ git mv <old_name> <new_file>
  8. 8. Git Logs (contd) $ git log –pretty=oneline (Pretty print the log) $ git log --pretty=format:"%h - %an, %ar : %s” $ git log –graph
  9. 9. Amending the Tree $ git commit –amend Example: $ git commit -m ’initial commit’ $ git add forgotten_file $ git commit –amend Be Careful while amending the tree because the changes are permanent!
  10. 10. Remote Repository $ git remote –v ( Name and URL of the remote server) $ git remote add <branch> <url of remote repo> $ git fetch <branchname> $ git remote rm <branchname> ( Use carefully) $ git pull
  11. 11. Git Branches Git branches are one of the most potent features of Git. Learn it and it may just change your life! $ git branch (List local branches) -a : List all branches, local and remote -t : Begin tracking a remote branch -d : Delete a branch $ git checkout –b <branchname> origin/branchname (Creates a branch and tracks the remote branchname)
  12. 12. Merging & Rebasing $ git merge <branchname> ( Merging another branch into this ) $ git rebase [basebranch] [topicbranch]( Plays the child commits on the master ) Interesting things can be done with rebase. Look at whiteboard! IMP: Don’t rebase stuff that has been committed to the remote repository! Such people are hated and stoned 
  13. 13. Interesting Features $ git bisect start $ git bisect good $ git bisect bad $ git bisect reset $ git bisect run testing.sh $ git diff (Useless for binary files) Add *.doc diff=word (In .gitattributes) $ git config diff.word.textconv strings Exiftool ( For JPEG Files)
  14. 14. Interesting Features Hooks (Server side and Client side) Pre-commit hooks Post-commit hooks $ git gc

×