Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Git
What is Git?
Distributed version control system (DVCS)
SVN = Centralized version control system
Mercurial, Bazaar are othe...
SVN (Centralized VCS) overview
Git (Distributed VCS) overview
Git (Distributed VCS) overview
(cont)
Why Git?
Embraced by all major hosting sites:
Github, Google Code, CodePlex, BitBucket
Used by major projects
Linux kernel...
• Able to work disconnected (ex. VPN / home)
o (Almost) everything is local, fast
o Log is always available
o Private work...
General workflow
File status lifecycle
Repository commits
Terms
HEAD
last commit of current branch
HEAD^
parent of HEAD
master
default development branch (trunk)
origin
default ups...
Terms (cont.)
HEAD^ == HEAD~1 # parent of HEAD
HEAD^^^ == HEAD~3
master^^^ == master ~3
git init
New
git clone <url>
Existing
run at the project's top-most directory
creates a .git directory
Initializing
Review previous commit
git show --stat
git show --name-status
info about last commit
git show HEAD
git show HEAD^^^
git sh...
Log
git log
git log --name-status
git log --oneline --graph --all
git log --author="Sean Lynch"
git log --grep="commit.*me...
Branching
git branch <branchname>
git checkout <branchname>
git checkout -b <branchname>
Create new branch and switch to
g...
Stashing
git stash
git stash [save message]
git stash list
git status apply
git stash clear
git stash branch <branchname>
Making a release (tagging)
git tag -a <name>
Create an annotated tag (with message)
git push --tags
Push tags to remote
gi...
Remotes
git remote -v
git remote add <name> <url>
git remote show <name>
git branch --set-upstream master origin/master
Se...
Updating (Push/Pull)
git fetch / git merge
Fetch latest changes from origin, need to
use git merge to apply.
git pull
Pull...
Reverting
git checkout .
Revert changes to all files into working directory,
overwriting any local changes. This is most s...
Reverting (cont.)
git reset HEAD
Unstage something
git reset HEAD^
forget about a commit, load it back into the staging ar...
Reverting (cont. more)
git commit --amend
Change last commit (correct the previous commit, with
the staged changes)
git re...
Getting Started
Install
Configuration
Ignores
Install
Windows
Git for Windows: http://msysgit.github.com/
Git Extensions:
http://code.google.com/p/gitextensions/
Tortoi...
Configuration
git config --global user.name "Sean Lynch"
git config --global user.email "sean.lynch@sbcs.com"
git config -...
Configuration (aliases)
git config --global alias.st status -s
git config --global alias.co checkout
git config --global a...
Ignores
git config --global core.excludesfile
~/.gitignore_global
Collection of .gitignore templates by language /
framewo...
Review
git init
git clone
git add
git status
git commit
git log
git branch
git checkout
git merge
git push
git fetch
git p...
Extras - Modifying history
git commit --amend
Modify previous commit. Useful to update
message or include missing file wit...
Extras
git submodule
git subtree
Finding regressions
git bisect start
git bisect good <commit>
git bisect bad <commit>
git bisect visualize
git bisect reset
Best practices
Don't develop off master, use
develop/feature/issue/etc branches
Help / Documentation / Reference
git <command> --help
http://gitref.org/
http://git-scm.com/book
http://help.github.com/
h...
Git
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Subversion to Git Migration
Next
Upcoming SlideShare
Subversion to Git Migration
Next
Download to read offline and view in fullscreen.

Share

Git

Download to read offline

General markers for GIT operations.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Git

  1. 1. Git
  2. 2. What is Git? Distributed version control system (DVCS) SVN = Centralized version control system Mercurial, Bazaar are other DVCS Initially designed and developed by Linus Torvalds to manage Linux kernel code base when BitKeeper revoked free license.
  3. 3. SVN (Centralized VCS) overview
  4. 4. Git (Distributed VCS) overview
  5. 5. Git (Distributed VCS) overview (cont)
  6. 6. Why Git? Embraced by all major hosting sites: Github, Google Code, CodePlex, BitBucket Used by major projects Linux kernel, Android, ASP.NET MVC, Facebook, Eclipse, Twitter Boostrap, ...
  7. 7. • Able to work disconnected (ex. VPN / home) o (Almost) everything is local, fast o Log is always available o Private workspace  Able to commit whenever, create snapshots, push when ready (off VPN, done hacking)  Share when ready, ability to modify previous commits before sharing • Local branching, easily switch gears when customer calls (isolate work units)  features, bug fixes, proof of concepts, etc Why Git? - Benefits
  8. 8. General workflow
  9. 9. File status lifecycle
  10. 10. Repository commits
  11. 11. Terms HEAD last commit of current branch HEAD^ parent of HEAD master default development branch (trunk) origin default upstream repository (name of remote when git clone was used)
  12. 12. Terms (cont.) HEAD^ == HEAD~1 # parent of HEAD HEAD^^^ == HEAD~3 master^^^ == master ~3
  13. 13. git init New git clone <url> Existing run at the project's top-most directory creates a .git directory Initializing
  14. 14. Review previous commit git show --stat git show --name-status info about last commit git show HEAD git show HEAD^^^ git show master~10 git show @{yesterday} git show master@{May.16}
  15. 15. Log git log git log --name-status git log --oneline --graph --all git log --author="Sean Lynch" git log --grep="commit.*message.*text" git log -- some/file limit by changes to specific file git timeline / git lol custom aliases
  16. 16. Branching git branch <branchname> git checkout <branchname> git checkout -b <branchname> Create new branch and switch to git branch [-a -l -r] List branches (all, local, remote) git merge <branchname> Merge branch into current branch (ex. master)
  17. 17. Stashing git stash git stash [save message] git stash list git status apply git stash clear git stash branch <branchname>
  18. 18. Making a release (tagging) git tag -a <name> Create an annotated tag (with message) git push --tags Push tags to remote git tag list all tags
  19. 19. Remotes git remote -v git remote add <name> <url> git remote show <name> git branch --set-upstream master origin/master Set local branch to track remote branch git svn http://git-scm.com/book/en/Git-and-Other-Systems-Git- and-Subversion
  20. 20. Updating (Push/Pull) git fetch / git merge Fetch latest changes from origin, need to use git merge to apply. git pull Pull latest changes from origin (fetch + merge) git push [remote_name] [branch_name]
  21. 21. Reverting git checkout . Revert changes to all files into working directory, overwriting any local changes. This is most similar to "svn revert" git checkout -- <filename> Revert changes to a file in working directory git log --diff-filter=D -- <filename> git checkout <deleting_commit>^ -- <filename> Restore a deleted file
  22. 22. Reverting (cont.) git reset HEAD Unstage something git reset HEAD^ forget about a commit, load it back into the staging area git reset --hard HEAD / git checkout -f Return to last committed state (discard all local changes). Can not be undone (without reflog)
  23. 23. Reverting (cont. more) git commit --amend Change last commit (correct the previous commit, with the staged changes) git revert HEAD Revert changes (creates a new commit)
  24. 24. Getting Started Install Configuration Ignores
  25. 25. Install Windows Git for Windows: http://msysgit.github.com/ Git Extensions: http://code.google.com/p/gitextensions/ TortoiseGit: http://code.google.com/p/tortoisegit/ Mac Homebrew: brew install git bash-completion SourceTree: http://www.sourcetreeapp.com/ GitHub for Mac: http://mac.github.com/
  26. 26. Configuration git config --global user.name "Sean Lynch" git config --global user.email "sean.lynch@sbcs.com" git config --global core.autocrlf true #Windows git config --global core.autocrlf input #Macs git config --global color.ui true git config --global log.decorate true git config --list cat ~/.gitconfig
  27. 27. Configuration (aliases) git config --global alias.st status -s git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.timeline=log --graph -- pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- date=relative --all
  28. 28. Ignores git config --global core.excludesfile ~/.gitignore_global Collection of .gitignore templates by language / framework https://github.com/github/gitignore
  29. 29. Review git init git clone git add git status git commit git log git branch git checkout git merge git push git fetch git pull
  30. 30. Extras - Modifying history git commit --amend Modify previous commit. Useful to update message or include missing file without creating a new commit git rebase -i Rewrite history. Squash, reorder, by dropping
  31. 31. Extras git submodule git subtree
  32. 32. Finding regressions git bisect start git bisect good <commit> git bisect bad <commit> git bisect visualize git bisect reset
  33. 33. Best practices Don't develop off master, use develop/feature/issue/etc branches
  34. 34. Help / Documentation / Reference git <command> --help http://gitref.org/ http://git-scm.com/book http://help.github.com/ http://www.codingdomain.com/git/tricks/ http://jonas.nitro.dk/git/quick-reference.html http://gitimmersion.com/ http://marklodato.github.com/visual-git-guide/

General markers for GIT operations.

Views

Total views

327

On Slideshare

0

From embeds

0

Number of embeds

2

Actions

Downloads

6

Shares

0

Comments

0

Likes

0

×