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}}
18 )))
19 1. (((
msp 27.1 20 Add and commit some content: copy [[attach:notes.txt]]{{code language="none"}}{{/code}} to your {{code language="none"}}turing{{/code}} directory.
msp 1.1 21
msp 24.1 22 {{noformat}}
msp 23.1 23 $ git add notes.txt
24 $ git commit -m "wrote some first notes"
25 [master (root-commit) 2e73b34] wrote some first notes
26 1 files changed, 5 insertions(+), 0 deletions(-)
27 create mode 100644 notes.txt
28 {{/noformat}}
29 )))
msp 24.1 30 1. Edit {{code language="none"}}notes.txt{{/code}}:\\
31 11. Replace "fixed" with "infinite" in line 1.
32 11. Replace "... (TODO)" with "a finite state machine" in line 4.
33 1. (((
msp 27.1 34 View the status of your current working copy:
35
36 {{noformat}}
37 $ git status
38 # On branch master
39 # Changed but not updated:
40 # (use "git add <file>..." to update what will be committed)
41 # (use "git checkout -- <file>..." to discard changes in working directory)
42 #
43 # modified: notes.txt
44 #
45 no changes added to commit (use "git add" and/or "git commit -a")
46 {{/noformat}}
47 )))
48 1. (((
49 Mark the modified file to include it in the next commit, then view the status again and compare with the previous output:
50
51 {{noformat}}
52 $ git add notes.txt
53 $ git status
54 # On branch master
55 # Changes to be committed:
56 # (use "git reset HEAD <file>..." to unstage)
57 #
58 # modified: notes.txt
59 #
60 {{/noformat}}
61 )))
62 1. (((
msp 24.1 63 Commit the modified content to your local repository:
64
65 {{noformat}}
66 $ git commit -m "modified tape length, found a controller for tape head"
msp 27.1 67 [master 52e2d49] modified tape length, found a controller for tape head
msp 24.1 68 1 files changed, 2 insertions(+), 2 deletions(-)
69 {{/noformat}}
70 )))
71
msp 26.1 72 After the preceding steps you have two commits in your local repository, each with one file in the index. You have different commands for viewing these commits:
msp 24.1 73
74 {{noformat}}
75 $ git log
msp 27.1 76 commit 52e2d4946791c2725015853e5e261ce143c6fe8a
msp 24.1 77 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
msp 27.1 78 Date: Mon Oct 15 15:00:14 2012 +0200
msp 24.1 79
80 modified tape length, found a controller for tape head
81
82 commit 2e73b34ac44480773fc0e52875b7353a087d8c6d
83 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
84 Date: Mon Oct 15 12:14:06 2012 +0200
85
86 wrote some first notes
87  
msp 27.1 88 $ $ git show 52e2d49
89 commit 52e2d4946791c2725015853e5e261ce143c6fe8a
msp 24.1 90 Author: Miro Spoenemann <msp@informatik.uni-kiel.de>
msp 27.1 91 Date: Mon Oct 15 15:00:14 2012 +0200
msp 24.1 92
93 modified tape length, found a controller for tape head
94
95 diff --git a/notes.txt b/notes.txt
96 index 4ded2b3..bd422b3 100644
97 --- a/notes.txt
98 +++ b/notes.txt
99 @@ -1,5 +1,5 @@
100 - * A tape with fixed length
101 + * A tape with infinite length
102 * Tape head can read or write data
103 * Tape head can move left or right
104 - * The head is controlled by ... (TODO)
105 + * The head is controlled by a finite state machine
106 {{/noformat}}
107
msp 27.1 108 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"}}52e2d49{{/code}} to identify the second commit. Also try the command {{code language="none"}}gitk{{/code}} to get an overview of your commits (a better alternative available for MacOS is [[GitX>>url:http://gitx.frim.nl/||shape="rect"]]).