550 likes | 1.02k Views
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
E N D
Introduction To Git Presented by: Muhammad RizwanArshad (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
GitVs Subversion • Distributed vsCenteralized. • Gitis 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
First-Time Git Setup • gitconfig --global user.name “myname“ • gitconfig --global user.emailuser@example.com • gitconfig --global core.editoremacs • gitconfig --global merge.toolvimdiff • gitconfig --list user.name=“myname” • gitconfig user.name
Getting a Git Repository • gitinit • git add *.c • git add README • git commit -m 'initial project version‘ • Clone a Repository: • gitclone git://github.com/schacon/grit.git mygrit
Recording Changes to the Repository • Checking the Status of Your Files • gitstatus • Tracking New Files • git add README • Ignoring Files • Edit .gitignore file • Committing Your Changes • gitcommit • git commit -m "Story 182: Fix benchmarks for speed"
Viewing the Commit History • gitlog • gitlog -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 “gitbranch 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 “gitcommit -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 “gitcommit -a -m 'made other changes‘”
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