Skip to content

Commit 02f6e3c

Browse files
committed
Add rest of slides
1 parent 9dee4b2 commit 02f6e3c

19 files changed

+591
-59
lines changed

.gitignore

+51
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,54 @@ presentation.sh
44
presentation.stdout
55
presentation.stderr
66
*.include
7+
8+
*~
9+
.DS_Store
10+
*.aux
11+
*.bbl
12+
*.blg
13+
*.nav
14+
*.snm
15+
*.vrb
16+
*.log
17+
*.toc
18+
*-skim.pdf
19+
20+
*.rej
21+
*.orig
22+
.*.sw?
23+
.sw?
24+
.vagrant/
25+
26+
x1
27+
x1.*
28+
*.pyc
29+
*.aux
30+
*.bbl
31+
*.blg
32+
*.dvi
33+
*.synctex.gz
34+
*.log
35+
*.o
36+
*.so
37+
*.so.dSYM
38+
*.dylib
39+
Thumbs.db
40+
*.orig
41+
*.rej
42+
tmp/
43+
.kitchen/
44+
binstubs/
45+
.gradle/
46+
!.gradle/init.d
47+
48+
notes.txt
49+
Makefile.local
50+
51+
.idea/
52+
*.ipr
53+
*.iws
54+
.rakeTasks
55+
.generators
56+
57+
.hg/

Makefile

+1-9
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,13 @@ PYTHON_FILES = $(wildcard *.py)
4343

4444
presentation.pdf: $(PYTHON_FILES:%.py=%.py.include)
4545

46-
%.py.include: %.py ./python-interpret
47-
echo -n > $@
48-
echo '\begin{verbatim}' >> $@
49-
./python-interpret < $*.py >> $@
50-
echo '\end{verbatim}' >> $@
51-
52-
%.py.out: %.py
53-
(echo 'import datetime'; cat $<) | python > $@
54-
5546
clean::
5647
rm -f *.out *.include
5748

5849
GH_CURL = curl -sSH "Authorization: token $$(grep oauth_token ~/.config/hub | head -n1 | awk '{print $$2}')"
5950

6051
upload: presentation.pdf
52+
git tag -f v0.0.0 && git push -f --tags github.com/py-yyc/git-init
6153
EXISTING_RELEASE_ID=$$(${GH_CURL} https://api.github.com/repos/py-yyc/git-init/releases/tags/v0.0.0 | jq .id); \
6254
if [ -n "$$EXISTING_RELEASE_ID" ]; then \
6355
${GH_CURL} -X DELETE https://api.github.com/repos/py-yyc/git-init/releases/$$EXISTING_RELEASE_ID; \

commits1

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
git init
2+
echo hi > foo
3+
git status
4+
git add foo
5+
git status
6+
git commit -m 'Add foo'
7+
8+
git rev-parse HEAD
9+
git cat-file -p HEAD
10+
git cat-file -p HEAD^{tree}
11+
git cat-file -p 45b983be36b73c0788dc9cbcb76cbb80fc7bb057
12+
13+
git cat-file commit HEAD | hexdump -C
14+
git cat-file tree HEAD^{tree} | hexdump -C
15+
git cat-file blob 45b983be36b73c0788dc9cbcb76cbb80fc7bb057 | hexdump -C

compute-hash

+2-12
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@ import os
44
import sys
55
import time
66
from hashlib import sha1
7-
from subprocess import check_call
7+
from fake_git import check_call, commit_metadata
88
from tempfile import TemporaryDirectory
99

1010
os.environ['GIT_PAGER'] = ''
1111

1212
commit_message = 'Add foo'
13-
commit_metadata = {
14-
'name': 'Andrew',
15-
'email': '[email protected]',
16-
'date': time.strftime('%s %z')
17-
}
18-
git_env = {('GIT_%s_%s' % (who.upper(), what.upper()), value)
19-
for who in ['author', 'committer']
20-
for what, value in commit_metadata.items()}
2113

2214
def hash(object_type, contents):
2315
return sha1(b'%s %d\0%s' % (object_type, len(contents), contents))
@@ -51,7 +43,5 @@ with TemporaryDirectory() as t:
5143
check_call(['git', 'init'])
5244
check_call(['git', 'add', 'foo'])
5345

54-
env = os.environ.copy()
55-
env.update(git_env)
56-
check_call(['git', 'commit', '-m', commit_message], env=env)
46+
check_call(['git', 'commit', '-m', commit_message])
5747
check_call(['git', 'log', '-m', 'foo'])

fake_git.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import subprocess
3+
4+
commit_metadata = {
5+
'name': 'Andrew',
6+
'email': '[email protected]',
7+
'date': '1515151515 -0700' # time.strftime('%s %z')
8+
}
9+
git_env = {('GIT_%s_%s' % (who.upper(), what.upper()), value)
10+
for who in ['author', 'committer']
11+
for what, value in commit_metadata.items()}
12+
13+
def check_call(args):
14+
env = os.environ.copy()
15+
env.update(git_env)
16+
return subprocess.check_call(args, env=env)

foo

-1
This file was deleted.

git-vs-hg.pdf

29.9 KB
Binary file not shown.

github-add-collaborator.png

15.3 KB
Loading

github-annotate.png

27.3 KB
Loading

github-commitdetails.png

24.5 KB
Loading

github-commitlog.png

27.4 KB
Loading

github-compare.png

10.8 KB
Loading

github-fork-button.png

845 Bytes
Loading

in-tmpdir

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from tempfile import TemporaryDirectory
6+
7+
os.environ['GIT_PAGER'] = ''
8+
from fake_git import check_call
9+
10+
with TemporaryDirectory() as t:
11+
os.chdir(t)
12+
for line in sys.stdin.read().split('\n'):
13+
if len(line) == 0:
14+
continue
15+
print('$ ' + line)
16+
sys.stdout.flush()
17+
check_call(['sh', '-c', line])

outline.txt

+36-16
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,50 @@
22

33
= Version Control
44

5-
Basics of version control
6-
- Tracking who made what changes, when, and why, gets very complicated
7-
- [Excel icon] budget.q4updated.final_FINAL_with_fixes_from_jim.xls
8-
- [Python logo] Imagine website.beta2.final_FINAL_with_bug_fix_from_susan.py,
9-
distributed by email :(
5+
What is version control and why should you use it?
6+
7+
Version control:
8+
- every code change is a distinct entity called a commit
9+
it has an attached record of who made the change, when they made it, and
10+
why they said they made the change
11+
12+
Why?
13+
- diff: show you what you’ve changed so you can review it
14+
- backups: can go back to a known good state if things start crashing,
15+
or an idea turns out not to work
16+
- undo: can selectively roll back individual changes
17+
- history: safely delete code to keep things clean instead of commenting
18+
it out, knowing you can get it back later if you want
19+
- context: commit messages can explain design decisions, link to bug
20+
reports
21+
- merges: if you make unrelated changes to different files, the version
22+
control system will merge them instead
23+
- fast way of sharing code: syncing with someone else only requires
24+
transmitting recent changes, not the complete source code
25+
- annotate: show who originally wrote the code, or changed it recently,
26+
so you know can ask them for help
27+
- bisect: find source of bugs by checking different versions to see when
28+
the bug first shows up
29+
30+
A nice orderly way of storing and managing source code
31+
whose only real competitor is complete chaos
1032

11-
Wouldn’t it be nice if computers tracked that automatically?
33+
- Indispensable when working with others: automatic merges
34+
- Useful even if the only other people working on the project are past you
35+
and future you: the code was working 10 minutes ago. What did I just
36+
change?
37+
38+
= Version control with git
39+
40+
GitHub does everything we talked about, in a nice Web UI
1241
- [Screenshots of github for everything here]
1342
- Commit log
1443
- Commit details
1544
- Tags attached to commits
1645
- Blame
1746

18-
Is it worth it?
19-
- Indispensable when working with others: automatic merges
20-
- Useful even if the only other people working on the project are past
21-
you and future you
22-
- The code was working 10 minutes ago. What did I just change?
23-
- Check older versions to see if the bug was always there, or you
24-
accidentally added it last week
25-
26-
= Version control with git
27-
2847
To use Github, you have to use git
48+
- Originally written by Linus Torvalds to store linux source code
2949
Can get very complicated very quickly
3050
- Used to use Mercurial
3151
- Found git ridiculously complicated

0 commit comments

Comments
 (0)