Changes for page Git
Last modified by Richard Kreissig on 2025/01/30 12:03
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,6 +1,6 @@ 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"]]. 2 2 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. 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 4 5 5 = Creating Commits = 6 6 ... ... @@ -7,14 +7,6 @@ 7 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 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 9 1. ((( 10 -Configure your name and email address (will be included in all commits you create): 11 - 12 -{{noformat}} 13 -$ git config --global --add user.name "Your Name" 14 -$ git config --global --add user.email "<login>@informatik.uni-kiel.de" 15 -{{/noformat}} 16 -))) 17 -1. ((( 18 18 Create a local repository for the "//Turing Project//": 19 19 20 20 {{noformat}} ... ... @@ -24,10 +24,12 @@ 24 24 Initialized empty Git repository in ~/turing/.git/ 25 25 {{/noformat}} 26 26 27 -The {{code language="none"}}.git{{/code}} subdirectory contains all history and metadata of the repository. You should not modify it. 19 +{{panel}} 20 +**$ mkdir turing $ cd turing $ git init**{{code language="none"}} Initialized empty Git repository in ~/turing/.git/{{/code}} 21 +{{/panel}} 28 28 ))) 29 29 1. ((( 30 -Add and commitsome content: copy [[attach:notes.txt]]{{code language="none"}}{{/code}} to your {{code language="none"}}turing{{/code}} directory.24 +Add some content: copy [[attach:notes.txt]]{{code language="none"}}{{/code}} to your {{code language="none"}}turing{{/code}} directory. 31 31 32 32 {{noformat}} 33 33 $ git add notes.txt ... ... @@ -36,61 +36,28 @@ 36 36 1 files changed, 5 insertions(+), 0 deletions(-) 37 37 create mode 100644 notes.txt 38 38 {{/noformat}} 39 - 40 -The file is now stored in the local history of your repository. 41 41 ))) 42 42 1. Edit {{code language="none"}}notes.txt{{/code}}:\\ 43 43 11. Replace "fixed" with "infinite" in line 1. 44 44 11. Replace "... (TODO)" with "a finite state machine" in line 4. 45 45 1. ((( 46 - Viewthestatusofyour current working copy:38 +Commit the modified content to your local repository: 47 47 48 48 {{noformat}} 49 -$ git status 50 -# On branch master 51 -# Changed but not updated: 52 -# (use "git add <file>..." to update what will be committed) 53 -# (use "git checkout -- <file>..." to discard changes in working directory) 54 -# 55 -# modified: notes.txt 56 -# 57 -no changes added to commit (use "git add" and/or "git commit -a") 58 -{{/noformat}} 59 -))) 60 -1. ((( 61 -Mark the modified file to include it in the next commit, then view the status again and compare with the previous output: 62 - 63 -{{noformat}} 64 64 $ git add notes.txt 65 -$ git status 66 -# On branch master 67 -# Changes to be committed: 68 -# (use "git reset HEAD <file>..." to unstage) 69 -# 70 -# modified: notes.txt 71 -# 72 -{{/noformat}} 73 -))) 74 -1. ((( 75 -Commit the modified content to your local repository and view the status: 76 - 77 -{{noformat}} 78 78 $ git commit -m "modified tape length, found a controller for tape head" 79 -[master 52e2d49] modified tape length, found a controller for tape head43 +[master 3f28a0e] modified tape length, found a controller for tape head 80 80 1 files changed, 2 insertions(+), 2 deletions(-) 81 -$ git status 82 -# On branch master 83 -nothing to commit (working directory clean) 84 84 {{/noformat}} 85 85 ))) 86 86 87 -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:48 +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: 88 88 89 89 {{noformat}} 90 90 $ git log 91 -commit 52e2d4946791c2725015853e5e261ce143c6fe8a52 +commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb5 92 92 Author: Miro Spoenemann <msp@informatik.uni-kiel.de> 93 -Date: Mon Oct 15 1 5:00:14 2012 +020054 +Date: Mon Oct 15 14:30:24 2012 +0200 94 94 95 95 modified tape length, found a controller for tape head 96 96 ... ... @@ -100,10 +100,10 @@ 100 100 101 101 wrote some first notes 102 102 103 -$ git show 52e2d49104 -commit 52e2d4946791c2725015853e5e261ce143c6fe8a64 +$ git show 3f28a0e 65 +commit 3f28a0e473bf3da4aff34a09fed838fe033f3bb5 105 105 Author: Miro Spoenemann <msp@informatik.uni-kiel.de> 106 -Date: Mon Oct 15 1 5:00:14 2012 +020067 +Date: Mon Oct 15 14:30:24 2012 +0200 107 107 108 108 modified tape length, found a controller for tape head 109 109 ... ... @@ -120,51 +120,4 @@ 120 120 + * The head is controlled by a finite state machine 121 121 {{/noformat}} 122 122 123 -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. The commit hashes in your repository will be different from those seen in this tutorial, because the name of the author and the exact time of committing is also considered in the hash calculation. 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"]]). 124 - 125 -= Branching and Merging = 126 - 127 -In the previous section you have created two commits on the default branch, which is named {{code language="none"}}master{{/code}}. Now you will create a new branch and commit there, thus adding complexity to the commit graph. 128 - 129 -1. ((( 130 -Create a branch with name //sketches//: 131 - 132 -{{noformat}} 133 -$ git branch sketches 134 -{{/noformat}} 135 -))) 136 -1. ((( 137 -View the list of branches: 138 - 139 -{{noformat}} 140 -$ git branch 141 -* master 142 - sketches 143 -{{/noformat}} 144 - 145 -The star reveals that you are still on the old {{code language="none"}}master{{/code}} branch. 146 -))) 147 -1. ((( 148 -Switch to the new branch: 149 - 150 -{{noformat}} 151 -$ git checkout sketches 152 -Switched to branch 'sketches' 153 -$ git branch 154 - master 155 -* sketches 156 -{{/noformat}} 157 - 158 -It is also possible to create a branch and switch immediately to it using the option {{code language="none"}}-b{{/code}} of {{code language="none"}}git checkout{{/code}}. 159 -))) 160 -1. ((( 161 -Add the new file [[attach:examples.txt]]: 162 - 163 -{{noformat}} 164 -$ git add examples.txt 165 -$ git commit -m "wrote first examples" 166 -[sketches cd63135] wrote first examples 167 - 1 files changed, 20 insertions(+), 0 deletions(-) 168 - create mode 100644 examples.txt 169 -{{/noformat}} 170 -))) 84 +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.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -29821 321 +2982116 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/29821 32/Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/2982116/Git