Date: Wed Apr 3 20:47:48 2019 -0500
Change up the order a bit.
...more of same from above...
```
---
## Who decided line 9 should be strange?!
`git blame`
```powershell
PS C:\Users\edthe\edthedev.github.io> git blame .\index.html
```
```powershell
3cbc7b3a (Edward Delaporte 2015-07-25 11:45:35 -0500 1)
3cbc7b3a (Edward Delaporte 2015-07-25 11:45:35 -0500 2)
e2e4117f (Edward Delaporte 2017-05-06 00:37:46 +0000 3)
e2e4117f (Edward Delaporte 2017-05-06 00:37:46 +0000 4)
e2e4117f (Edward Delaporte 2017-05-06 00:37:46 +0000 5)
e2e4117f (Edward Delaporte 2017-05-06 00:37:46 +0000 6)
e2e4117f (Edward Delaporte 2017-05-06 00:37:46 +0000 7)
4bf3f64c (Edward Delaporte 2017-05-06 05:10:05 +0000 8)
7cf65857 (Edward Delaporte 2015-07-25 12:19:15 -0500 12)
3cbc7b3a (Edward Delaporte 2015-07-25 11:45:35 -0500 13)
```
???
+ Each line of the file.
+ Who last modified each line.
+ When last modified each line.
---
## Pretty Tools
[Tortoise Git](https://tortoisegit.org/)
- Add right-click menu items to Windows Explorer
- Like TortoiseSvn, but for Git
Atlassian SourceTree
- [Atlassian SourceTree for Mac and Windows](https://www.sourcetreeapp.com/)
GitHub Desktop
- [GitHub Desktop](https://desktop.github.com/)
???
Tortoise - Right click can be fun
SourceTree
- Point and click your way through Git history
- Visual branch/merge history
- See past revisions
- Diff between arbitrary revisions
- Manage branches and branch operations in a visual way
---
## Pretty Tools
Visual Studio Code
- [Free/Open/Cross Platform from Microsoft](https://code.visualstudio.com/)
- [GitLens Plugin](https://github.com/eamodio/vscode-gitlens/tree/master/#code-lens-)
- Other great plugins include: VsVim, RainbowCSV, Markdown Paste, Markdown PDF
???
VSCode
- VsCode Handles git out of the box.
- Searching Git in the plugin marketplace returned 5 pages of results.
- Code Lens - see who changed which line last
- Various visual ways to explore history
- Native integrated shell
---
## I committed on `master`
If you're lucky, and it was only a commit or two
```
# Find my commit is named 0219e5ce9
git log
# Where I meant to be
git checkout -b story_0700
git cherry-pick 0219e5ce9
# Clean up local master
git checkout master
git reset --hard origin/master
# Back to work
git checkout story_0700
```
---
## I committed on `master`
If you committed a lot, and want to use commands you understand
```
# Making a new branch brings along your unpushed commits)
git checkout -b story_0700_temp
# Clean up local master
git checkout master
git reset --hard origin/master
# Get back to work
git checkout story_0700
git merge story_0700_temp
# Clean up
git branch -D story_0700_temp
```
---
## I committed on `master`
If you used Stack Overlfow, you may see something more like this.
It keeps your commit history cleaner.
```
# New branch (brings your unpushed commits)
git checkout -b story_0700
# Cleaner (to history) way to get caught up
git rebase develop
# Clean up local master
git checkout -B master origin/master
# Back to work
git checkout story_0700
```
---
## How to protect `master`
```
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
(At the repo)
Create file .git/hooks/pre-commit with following content:
if [ "$branch" = "master" ]; then
echo "You can't commit directly to master branch"
exit 1
fi
```
Make it executable (not required on Windows):
```
$ chmod +x .git/hooks/pre-commit
```
[Full solution at Stack Overflow][10]
[10]: https://stackoverflow.com/questions/40462111/git-prevent-commits-in-master-branch
???
+ Git hooks are just shell scripts.
+ You can and should do more with them.
+ You can make your chat bot cuss out whoever broke the build or forgot to comment.
---
## Discuss
???
- You can find this slide deck at Edward.Delaporte.us
---
---
## git checkout --patch
```
PS C:\Users\edthe\edthedev.github.io> git checkout --patch 57f04be6c2d85684869a3194c6a8a24859e60f59
diff --git b/ITProForum2019Spring.html a/ITProForum2019Spring.html
index 652d5ca..52e0f9e 100644
--- b/ITProForum2019Spring.html
+++ a/ITProForum2019Spring.html
@@ -19,7 +19,7 @@
}
.remark-slide-content {
- background-image: url("img/itpro2019spring/background.png");
+ background-image: url("img/itpro2018/bg_others.jpg");
}
img {
float:right;
Apply this hunk to index and worktree [y,n,q,a,d,j,J,g,/,e,?]?
```
---
## What else can `git diff` do?
[Quite a bit][2]
[2]: https://git-scm.com/docs/git-diff
```
git diff [
] [] [--] […]
git diff [] --cached [] [--] […]
git diff [] [--] […]
git diff []
git diff [] --no-index [--]
```
???
- Diff can do more
- but the default target is the last commit