Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years.

Similar presentations


Presentation on theme: "Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years."— Presentation transcript:

1 Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years

2 Who is this talk for ● Those who understand the basic concepts of Version Control ● People who like flexible powerful version control tools

3 What will we cover ● 1. How to use git on a daily basis. ● 2. Basic concepts of Git ● 3. High level of some differences between git and other systems. ● Not too much as honetsly as I have very little experience in other systems (a smidge of SVN, copy and pasted some CVS commands from drupal.org)

4 What we might cover ● Advanced Git concpets ● What we won't cover ● 1. Other systems (SVN, Mecurial, CVS, Source Save, etc...) ● 2. More obscure git commands like bisect, am, archive, notes, etc... ● 3. GUI tools, sorry but I use Vim and terminal. :D

5 Git History - Built by Linus Torvalds to be the source control system for the Linux Kernel when the Kernel project lost access to it's free BitKeeper license. - What's in a name? “The word Git: Linus Torvalds has quipped about the name "git", which is English slang for a stupid or unpleasant person. Torvalds said: "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'."”

6 Resources ● Git's web site: http://git-scm.com (Home of Pro Git book)http://git-scm.com ● Kernel.org man page: http://www.kernel.org/pub/software/scm/git/docs /user-manual.html ● Drupal Git documentation: http://drupal.org/documentation/git ● Tutorial: http://gitimmersion.com/ ● Git Hub: https://github.com ● Gitorious http://gitorious.org

7 Distributed vs. Central version control systems ● With distributed version control systems all changes are local until the developer/manager decides to push them to the remote repository. ● The most important thing here is this means developers can commit their code to version control but only share it when they are ready.

8 Getting started ● Clone the remote repository ● Cmd: “git clone” – Equivelant to “git pull” followed by “git merge” ● Start an empty repository and pull don code from a remote ● Cmd: “git init” ● Cmd: “git pull” ● In both cases the entire repository is pulled onto you machine, including the entire history/logs

9 Checkout, how its different ● With Git Checkout updates you code to the latest version in the LOCAL repository. Checkout does not touch the remote repository (that's what pull and fetch do). ● If you want to undo the change you made you simply checkout the file(s).

10 HEAD ● HEAD simply point to the latest active commit, not the actve remote branch

11 Remote repos ● You do not touch the remote repo until you push to the remote repo. ● Git allows you to push to any remote repo you have access to ● You can push you branches and tag to the repo or push to the repos master (ie HEAD in CVS) branch.

12 Git commits ● Much like any other VCS commits refer to the commitment of code (new or changed) to the repository. ● All commits are tracked using a unique sha1 hash (99.9999999999999% unique across all repos) ● Git commits are snapshot of the current files in the repo with a reference to their parent(s) commit(s).

13 Committed, staged, working changes ● Once you commit Git assumes any new changes will be committed later. You can view the last commit of files about to be committed. ● If it's commited it in the repo ● Cmd: “git show” – displays the last commited changes ● Staged: done editing it but have not committed. ● Cmd: “git diff --staged” ● Working means it's in progress and may or may not get committed. ● Cmd: “git diff”

14 The act of committing ● Before you commit ● Git diff ( I know this sounds funny but you will chach things like debug statements you left in your code when you do this) ● Stage your changed file ● Cmd: “git add” ● Commit your changes ● Cmd: “git commit”

15 Changing a commit ● You can amend a commit, especially the last commit ● Cmd: “git commit –amend” – Change the commit message – Add and commit new files in the same commit

16 Removing a commit ● You can remove a commit altogether ● git reset allows you to roll back the last commit ● Cmd: “git reset –soft” – uncommits the last changes leaving the files in their changed state ● Cmd: “git reset –hard” – uncommits the last change deleting the last change altogether ● You can uncommit more than one change uaing HEAD~n, ie “git reset HEAD~2” to uncommit the last two changes

17 Stash changes ● If you are in the middle of something and want to save you working changes without commiting ● Cmd: “git stash” ● saves your changes which can be retireved using ● Cmd: “git stash apply” ● Retrieves the last stashed changes

18 Git branches ● Branches version of the code base that diverge from the “master” version ● You can have an unlimited number of branches ● Branches in Git a uber lightweight (they are single files with nothing but a sha1 hash of the last latest commit) ● You can easily delete branches, if you mess up and need one of the commit in a branch you can recover it (hint “git reflog” then checkout, merge or cherry-pick) ● You can push you entire branch to a remote repo

19 Merge/Rebase ● Merge ● Merge another branch into the currently checked out branch ● The merge creates a commit with two parent commits, the last commits form the merged branches ● Rebase ● Similar to merge expect any commit not in the branch you merged from become the most recent, the HEAD commit has only one parent commit ● Rebase on a pull – git pull --rebase

20 Aliases ● Git allow you to alias commaned (ala Nix) ● So you can replace ”git checkout” with “git co” ● Or say you and one command to add all the modified file in your repository ● addmod = !git ls-files -z --modified | xargs -0 git add ● You type “git addmod” ● Aliases are added to a file named.gitconfig (typically stored in your home directory, ie ~/.gitconfig) ● ex.gitconfig file https://gist.github.com/4169120

21 Questions?


Download ppt "Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years."

Similar presentations


Ads by Google