Hide last authors
msp 23.1 1 This tutorial will address the source code management (SCM) tool named [[Git>>url:http://git-scm.com/||shape="rect"]]. By following these steps you should learn about the basic usage of Git, which is required for the whole practical course. Furthermore, Git is a great SCM tool, and it's good to know how to use it. During this tutorial, we will follow Alan Turing's thoughts towards developing the [[Turing Machine>>url:http://en.wikipedia.org/wiki/Turing_machine||shape="rect"]].
msp 1.1 2
msp 23.1 3 More in-depth documentation can be found on the [[official home page>>url:http://git-scm.com/documentation||shape="rect"]], which mentions books, videos, and links to other tutorials and references.
4
msp 24.1 5 = Creating Commits =
msp 1.1 6
msp 23.1 7 1. Read the [[Git for Computer Scientists>>url:http://eagain.net/articles/git-for-computer-scientists/||shape="rect"]] introduction (skip this if you are already familiar with Git).
8 1. For Linux, Git is available in its own package. Windows users can install [[msysGit>>url:http://msysgit.github.com/||shape="rect"]]. For MacOS, Git is available as part of [[Xcode>>url:https://developer.apple.com/xcode/||shape="rect"]]; if you cannot install that, use [[Git for OSX>>url:http://code.google.com/p/git-osx-installer/||shape="rect"]].
9 1. (((
10 Create a local repository for the "//Turing Project//":
msp 1.1 11
msp 24.1 12 {{noformat}}
msp 23.1 13 $ mkdir turing
14 $ cd turing
15 $ git init
16 Initialized empty Git repository in ~/turing/.git/
17 {{/noformat}}
msp 24.1 18
19 {{panel}}
msp 25.1 20 **$ mkdir turing**{{code language="none"}}{{/code}}
21
22 **$ cd turing**{{code language="none"}}{{/code}}
23
24 **$ git init**{{code language="none"}}{{/code}}
25
26 {{code language="none"}}Initialized empty Git repository in ~/turing/.git/{{/code}}
msp 24.1 27 {{/panel}}
msp 25.1 28
29 {{code language="bash"}}
30 $ mkdir turing
31 $ cd turing
32 $ git init
33 Initialized empty Git repository in ~/turing/.git/
34 {{/code}}
msp 23.1 35 )))
36 1. (((
msp 24.1 37 Add some content: copy [[attach:notes.txt]]{{code language="none"}}{{/code}} to your {{code language="none"}}turing{{/code}} directory.
msp 1.1 38
msp 24.1 39 {{noformat}}
msp 23.1 40 $ git add notes.txt
41 $ git commit -m "wrote some first notes"
42 [master (root-commit) 2e73b34] wrote some first notes
43 1 files changed, 5 insertions(+), 0 deletions(-)
44 create mode 100644 notes.txt
45 {{/noformat}}
46 )))
msp 24.1 47 1. Edit {{code language="none"}}notes.txt{{/code}}:\\
48 11. Replace "fixed" with "infinite" in line 1.
49 11. Replace "... (TODO)" with "a finite state machine" in line 4.
50 1. (((
51 Commit the modified content to your local repository:
52
53 {{noformat}}
54 $ git add notes.txt
55 $ git commit -m "modified tape length, found a controller for tape head"
56 [master 3f28a0e] modified tape length, found a controller for tape head
57 1 files changed, 2 insertions(+), 2 deletions(-)
58 {{/noformat}}
59 )))
60
61 After the preceding steps you have two commits in your local repository, each with one file in the index. You have different options for viewing these commits:
62
63 {{noformat}}
64 $ git log
65 commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb5
66 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
67 Date: Mon Oct 15 14:30:24 2012 +0200
68
69 modified tape length, found a controller for tape head
70
71 commit 2e73b34ac44480773fc0e52875b7353a087d8c6d
72 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
73 Date: Mon Oct 15 12:14:06 2012 +0200
74
75 wrote some first notes
76  
77 $ git show 3f28a0e
78 commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb5
79 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
80 Date: Mon Oct 15 14:30:24 2012 +0200
81
82 modified tape length, found a controller for tape head
83
84 diff --git a/notes.txt b/notes.txt
85 index 4ded2b3..bd422b3 100644
86 --- a/notes.txt
87 +++ b/notes.txt
88 @@ -1,5 +1,5 @@
89 - * A tape with fixed length
90 + * A tape with infinite length
91 * Tape head can read or write data
92 * Tape head can move left or right
93 - * The head is controlled by ... (TODO)
94 + * The head is controlled by a finite state machine
95 {{/noformat}}
96
97 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 {{code language="none"}}3f28a0e{{/code}} to identify the second commit.