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. 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. 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. 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.
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>
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. 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. 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. 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. 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)