Download - Introduction To Git
INTRODUCTION TO GIT
Presented by:Muhammad Rizwan Arshad
(PSE) VTeams
Presented at:Nextbridge LHR C1
February 28, 2013
Version Control
• System that records changes to a file or set of files over time
• You can recall specific versions later• Any type of file on a computer can be placed
under version control.• Version Control Systems– Local Version Control Systems– Centralized Version Control Systems– Distributed Version Control Systems
Local Version Control Systems
Centralized Version Control Systems
Distributed Version Control Systems
Git Vs Subversion
• Distributed vs Centeralized.• Git is incredibly fast and small as well.• Branches are even cheaper than they are in
Subversion.• Branch merging is simpler and more automatic in
Git.• Creating a repository is a trivial operation in Git.• The repository's internal file formats are incredible
simple in Git.
How Git works?
• Snapshots, Not Differences• Nearly Every Operation Is Local• Git Has Integrity• Git Generally Only Adds Data
The Three States
First-Time Git Setup
• git config --global user.name “myname“• git config --global user.email
[email protected]• git config --global core.editor emacs• git config --global merge.tool vimdiff• git config --list user.name=“myname”• git config user.name
Getting a Git Repository
• git init• git add *.c• git add README• git commit -m 'initial project version‘• Clone a Repository:– git clone git://github.com/schacon/grit.git mygrit
File Status Life Cycle
Recording Changes to the Repository
• Checking the Status of Your Files– git status
• Tracking New Files– git add README
• Ignoring Files– Edit .gitignore file
• Committing Your Changes– git commit– git commit -m "Story 182: Fix benchmarks for speed"
Viewing the Commit History
• git log• git log -p -2• git log –stat• git log --pretty=oneline• git log --since=2.weeks• Using a GUI to Visualize History– gitk
What a Branch Is• A lightweight movable pointer• Default branch name is MASTER• What happens when you create a new commit ?
What a Branch Is• Command “git branch testing”• How does Git know what branch you’re currently on?
What a Branch Is• Switch to an existing branch• Command “git checkout testing”
What a Branch Is• What is the significance of that? Well, let’s do another commit• Command “git commit -a -m 'made a change‘”
What a Branch Is• Let’s switch back to the master branch• Command “git checkout master”
What a Branch Is
• Command “git commit -a -m 'made other changes‘”
What a Branch Is
Basic Branching and Merging
Have a couple of commits already
• you’re going to work on issue #53• Is it issue-tracking system• Create a new branch• Command: git checkout –b iss53• That is shorthand command
Basic Branching and Merging
git commit -a -m 'added a new footer [issue 53]'
• git checkout -b hotfix• git commit -a -m 'fixed the broken email address‘• git checkout master
Basic Branching and Merging
• git merge hotfix• git branch -d hotfix
• git checkout iss53• git commit -a -m 'finished the new footer [issue 53]‘• git checkout master• git merge iss53
Basic Branching and Merging
Conflict Handling
QUESTIONS?