Child pages
  • Git

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Read the Git for Computer Scientists introduction (skip this if you are already familiar with Git). 
  2. For Linux, Git is available in its own package. Windows users can install msysGit. For MacOS, Git is available as part of Xcode; if you cannot install that, use Git for OSX.
  3. Create a local repository for the "Turing Project":

    No Format
    $ mkdir turing
    $ cd turing
    $ git init
    Initialized empty Git repository in ~/turing/.git/
  4. Add and commit some content: copy notes.txt to your turing directory.

    No Format
    $ git add notes.txt
    $ git commit -m "wrote some first notes"
    [master (root-commit) 2e73b34] wrote some first notes
     1 files changed, 5 insertions(+), 0 deletions(-)
     create mode 100644 notes.txt
  5. Edit notes.txt:
    1. Replace "fixed" with "infinite" in line 1.
    2. Replace "... (TODO)" with "a finite state machine" in line 4.
  6. View the status of your current working copy:

    No Format
    $ git status
    # On branch master
    # Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>.
    Commit the modified content to your local repository
    .." to discard changes in working directory)
    #
    #       modified:   notes.txt
    #
    no changes added to commit (use "git add" and/or "git commit -a")
  7. Mark the modified file to include it in the next commit, then view the status again and compare with the previous output:

    No Format
    $ git add notes.txt
    $ git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       modified:   notes.txt
    #
  8. Commit the modified content to your local repository:

    No Format
    $ git commit -m "modified tape length, found a controller for tape head"
    [master 3f28a0e52e2d49] modified tape length, found a controller for tape head
     1 files changed, 2 insertions(+), 2 deletions(-)

...

No Format
$ git log
commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb552e2d4946791c2725015853e5e261ce143c6fe8a
Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
Date:   Mon Oct 15 1415:3000:2414 2012 +0200

    modified tape length, found a controller for tape head

commit 2e73b34ac44480773fc0e52875b7353a087d8c6d
Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
Date:   Mon Oct 15 12:14:06 2012 +0200

    wrote some first notes
 
$ $ git show 3f28a0e52e2d49
commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb552e2d4946791c2725015853e5e261ce143c6fe8a
Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
Date:   Mon Oct 15 1415:3000:2414 2012 +0200

    modified tape length, found a controller for tape head

diff --git a/notes.txt b/notes.txt
index 4ded2b3..bd422b3 100644
--- a/notes.txt
+++ b/notes.txt
@@ -1,5 +1,5 @@
- * A tape with fixed length
+ * A tape with infinite length
  * Tape head can read or write data
  * Tape head can move left or right
- * The head is controlled by ... (TODO)
+ * The head is controlled by a finite state machine

Note that each commit is identified by a looong hash value, but it is possible to use only a prefix when referencing them (if the prefix is not ambiguous): the example above uses 3f28a0e to 52e2d49 to identify the second commit. Also try the command gitk to get an overview of your commits (a better alternative available for MacOS is GitX).