git one day training notes
DESCRIPTION
Download the powerpoint and checkout the speaker notes for some ideas around exercises.TRANSCRIPT
![Page 1: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/1.jpg)
Git Quickstart
Revision Control for Rock Stars
![Page 2: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/2.jpg)
Introductions
How would you know this course was valuable a week from now?
![Page 3: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/3.jpg)
Course Outline
• Getting Setup• Git: The Big Picture• Everyday Git• Branching• Merging & Rebasing• Other Random Gitness• Putting It All Together• Where to from here?
![Page 4: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/4.jpg)
Outcomes & Compentencies
• Install and Configure Git for Windows• Create local and shared Git repos• Add, Remove & Commit Files to repos• View History of Files / Work with Diffs & Blames• Branch, Tag and Merge & Rebase Branches
(with Conflicts)• Back out of trouble & drama• Be able to Push, Pull, Fetch, Clone, Diff &
Branch Remote Repos• Formulating Team Workflows with Git
![Page 5: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/5.jpg)
Philosophy
• “One must learn by doing the thing; for though you think you know it, you have no certainty, until you try.” Sophocles
• “Where there are no oxen, the manger is clean, but abundant crops come by the strength of an ox.” Jewish Proverb.
• Experiment. Go Crazy. Type like a madman.
![Page 6: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/6.jpg)
MODULE 0: GIT - THE BIG PICTURE
What? When? Why?
![Page 7: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/7.jpg)
Git: The Big Picture
![Page 8: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/8.jpg)
Use Cases
• Individual Developer• Local Workgroup• Distributed Workgroup• Offline Usages
![Page 9: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/9.jpg)
Git vs Svn vs CVS vs ?
• Snapshots, not diffs• Blobs• Everything is local• Everything is fast
![Page 10: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/10.jpg)
What’s This “Commit” Thing?
7ef7ab ef3ad2 22e4ff
File1.txtFile2.txt
File3.txtFile1.txt
File4.txt
![Page 11: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/11.jpg)
Git WorkflowWorkin
g Directo
ryStaging
Area (Index)
Repository
Add
Commit
Checkout
![Page 12: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/12.jpg)
1. GETTING SETUPGetting things installed…
![Page 13: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/13.jpg)
GUIs or Commandline or IDE?
• Git Bash• Posh Git (Powershell)• GitHub for Windows• Tortoise Git• Eclipse Git / IntelliJ Git / Visual Studio
Git Plugin / etc
![Page 14: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/14.jpg)
Download Git for Windows
![Page 15: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/15.jpg)
Installation Options
![Page 16: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/16.jpg)
The Magic Path Dialog
![Page 17: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/17.jpg)
Checkout Conventions
![Page 18: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/18.jpg)
Commandline Once-off Magic
• git config --global user.name “Glen Smith”
• git config --global user.email “[email protected]”
• git config -l [--global]• git help config
![Page 19: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/19.jpg)
MODULE 2: EVERYDAY GITThings you’ll use every single day…
![Page 20: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/20.jpg)
Everyday Git: Getting Committed
• git init .• git init myproject
• git status
• echo This is a sample file > sample.txt
![Page 21: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/21.jpg)
Adding and Committing
• git add .• git add myfile.txt myotherfile.txt• git add “**.txt”• git status• git commit -m “My first commit!”• git commit• git commit -am “Add all files and
commit. I live on the edge”
![Page 22: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/22.jpg)
Formatting Commits
• set GIT_EDITOR=notepad• git config --global core.editor
“notepad“
• First line for short form.• Second line blank.• Third line for a long description of the
commit
![Page 23: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/23.jpg)
Diff & Blame
• git diff• git blame /path/to/my/file.txt• git gui blame /path/to/my/file.txt• git whatchanged /path/to/my/file.txt • gitk /path/to/my/file.txt
![Page 24: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/24.jpg)
Viewing History
• git log • git log --oneline• git log --oneline -3• git log -p• git log --since “last week” --until “2
days ago”• gitk
![Page 25: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/25.jpg)
What’s with the SHA1?
![Page 26: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/26.jpg)
Deleting and Renaming Files
• git rm badfile.txt
• git mv oldname.txt newname.txt
• git clean -n (dry run)• git clean -f (force)
![Page 27: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/27.jpg)
Ignoring Files
• .gitignore• Ignore file(s), directories, patterns
(one per line)• Great for ignoring files and
directories in your project• Specially good for build artefacts and
generated binaries
![Page 28: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/28.jpg)
Unstaging a File
• git reset HEAD myfile.txt• git checkout myfile.txt• git rm –cached myfile (only pre first
commit)
![Page 29: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/29.jpg)
Amending A Commit
• (stage the files you want)• git commit --amend
![Page 30: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/30.jpg)
The Reflog
• git reflog• git checkout <your-commit-sha1>• git checkout master
![Page 31: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/31.jpg)
MODULE 3: BRANCHING & TAGGING
Working with Lines of Development
![Page 32: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/32.jpg)
Our Story So Far…
7ef7ab ef3ad2 22e4ff
![Page 33: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/33.jpg)
What could you use branches for?
• Bug fixes• Experimental features• Release branches• Integration Branches (CI)
![Page 34: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/34.jpg)
In Reality…
7ef7ab ef3ad2 22e4ff
ab4efa 6e3fd1
ee7ee7
Developer Branches for
an experimental
feature..
Merges his Changes back to the master
![Page 35: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/35.jpg)
Branching
• git branch• git branch mynewbranch• git checkout mynewbranch• git checkout -b
mynewcheckedoutbranch• git branch -d deletethatbranch
![Page 36: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/36.jpg)
Stashing
• git stash• git stash list• git stash apply• git stash pop• git stash clear
![Page 37: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/37.jpg)
Merging
• git merge branchname• git log master..dev
22e4ff
6e3fd1
ee7ee7
Merge creates a new commit with two parents
![Page 38: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/38.jpg)
Handling Conflicts
• git status• git checkout --ours myfile.txt• git checkout --theirs theirfile.txt
![Page 39: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/39.jpg)
Helpful Branch Tools
• gitk• git log --graph --oneline
![Page 40: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/40.jpg)
Tagging
• git tag 1.0• git tag -f 1.0• git tag -a 1.0• git tag
![Page 41: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/41.jpg)
Working with Remotes
• mkdir ourrepo.git• cd ourrepo.git• git init --bare• git clone file://c:/data/shared/ourrepo.git (or)• git remote add origin file://
c:/data/shared/ourrepo.git• git push origin master• git remote -v
![Page 42: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/42.jpg)
Pushing, Fetching, Pulling
• git pull• git fetch• git push• git push --tags• git log master..origin/master
![Page 43: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/43.jpg)
Remote Branches
• git push origin mybranch• git push origin• git branch -r• git checkout -b mybranch
origin/mybranch
• git config --global push.default matching
• git config --global push.default simple
![Page 44: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/44.jpg)
Deleting Remotes
• git branch -r • git push origin :mybranch• git push origin --delete mybranch• git remote prune
![Page 45: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/45.jpg)
MODULE 4: MERGING AND REBASING
![Page 46: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/46.jpg)
Back in the Day..
7ef7ab ef3ad2 22e4ff
ab4efa 6e3fd1
ee7ee7
Developer Branches for
an experimental
feature..
Merges his Changes back to the master
![Page 47: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/47.jpg)
Enter The Rebase…
7ef7ab ef3ad2 22e4ff
fad3e1ab23d
6
ee7ee7
![Page 48: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/48.jpg)
Warning!
• ONLY rebase on a local repo, never rewrite shared history
• If you’ve pushed your changes, live with it
• You can use git revert to develop compensating commits
![Page 49: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/49.jpg)
Rebase Essentials
• git checkout mybranch• git rebase master• git checkout master• git merge mybranch
![Page 50: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/50.jpg)
And when there are conflicts?
• git rebase --abort• git rebase --skip• git rebase --continue
![Page 51: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/51.jpg)
Rewrite History with Rebase
• git rebase -i <parent-of-the-commit-to-start-from>
• (entries will appear from oldest to newest)
![Page 52: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/52.jpg)
MODULE 5: OTHER RANDOM GITNESS
Stuff that doesn’t fit elsewhere…
![Page 53: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/53.jpg)
Git Aliases
• git config --global alias.co checkout• git config --global alias.ll “log --
oneline –graph” • git config -l• git config --unset alias.ll
![Page 54: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/54.jpg)
Soft and Hard Resets
• Provide a way of moving HEAD in your current branch
• Hard resets throw away working tree• Soft resets preserve working
7ef7ab ef3ad2 22e4ff ee7ee7
Normally HEAD would point to here
![Page 55: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/55.jpg)
Deployment Options
• Create a bare repo on the shared drive and use file: protocol
• Host it on a shared Unix host and use the ssh: protocol
• Run a local git daemon!
![Page 56: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/56.jpg)
Submodules
• git submodule add <your-git-submodule-repo>
• git submodule init• git submodule update
![Page 57: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/57.jpg)
Git Revert
![Page 58: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/58.jpg)
Git Bundle
![Page 59: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/59.jpg)
MODULE 6: PUTTING IT ALL TOGETHER
![Page 60: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/60.jpg)
Choosing a Team Workflow
1. Master is always golden (merge from CI/Dev branch)
2. Branch off master approaching release
3. Release Branch Centric4. <Your Strategy Here>
![Page 61: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/61.jpg)
Git(hub) Flows
• Anything in master is deployable• To work on something new, create a
new named branch off master and push it remotely
• After signoff, merge it to master (via a Jenkins job!)
![Page 62: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/62.jpg)
The Monster Exercise
![Page 63: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/63.jpg)
MODULE 7: WHERE TO FROM HERE?
Now you know the basics…
![Page 64: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/64.jpg)
Useful Books & Videos
![Page 65: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/65.jpg)
Useful Sites
• http://refcardz.dzone.com/refcardz/getting-started-git
• http://git-scm.com/book
• http://stackoverflow.com/questions/tagged/git
• http://try.github.com
![Page 66: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/66.jpg)
Please Help Us Improve
• Please fill in a feedback card telling us how we can improve this experience
• We’d love a testimonial too
![Page 67: Git One Day Training Notes](https://reader036.vdocument.in/reader036/viewer/2022062312/5549a16bb4c9050c738b4ecb/html5/thumbnails/67.jpg)
Thanks for Coming!
• Go forth and Git!