Skip to content

Instantly share code, notes, and snippets.

@ojacobson
Created November 5, 2012 19:51
Show Gist options
  • Save ojacobson/4019936 to your computer and use it in GitHub Desktop.
Save ojacobson/4019936 to your computer and use it in GitHub Desktop.
:)owen@dashie:Development$ git init pyc-problem
Initialized empty Git repository in /Users/owen/Development/pyc-problem/.git/
:)owen@dashie:Development$ cd pyc-problem/
:)owen@dashie:pyc-problem (master #)$ echo 'value = "before"' > foo.py
:)owen@dashie:pyc-problem (master #)$ cat > script <<'SCRIPT'
> #!/usr/bin/env python
>
> import foo
> print foo.value
> SCRIPT
:)owen@dashie:pyc-problem (master #)$ chmod +x script
:)owen@dashie:pyc-problem (master #)$ ./script
before
:)owen@dashie:pyc-problem (master #)$ ls
foo.py foo.pyc script
:)owen@dashie:pyc-problem (master #)$ git add foo.py script
:)owen@dashie:pyc-problem (master #)$ git commit -m 'Original state.'
[master (root-commit) afbf319] Original state.
2 files changed, 5 insertions(+)
create mode 100644 foo.py
create mode 100755 script
:)owen@dashie:pyc-problem (master)$ ls
foo.py foo.pyc script
:)owen@dashie:pyc-problem (master)$ echo 'value = "after"' > foo.py
:)owen@dashie:pyc-problem (master *)$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo.py
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo.pyc
no changes added to commit (use "git add" and/or "git commit -a")
:)owen@dashie:pyc-problem (master *)$ ./script
after
:)owen@dashie:pyc-problem (master *)$ git add foo.py
:)owen@dashie:pyc-problem (master +)$ git commit -m 'Post-edit state.'
[master 9298eab] Post-edit state.
1 file changed, 1 insertion(+), 1 deletion(-)
:)owen@dashie:pyc-problem (master)$ git checkout HEAD~
[…detatched HEAD warning…]
HEAD is now at afbf319... Original state.
:)owen@dashie:pyc-problem ((afbf319...))$ ./script
before
:)owen@dashie:pyc-problem ((afbf319...))$ git checkout master
Previous HEAD position was afbf319... Original state.
Switched to branch 'master'
:)owen@dashie:pyc-problem (master)$ ./script
after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment