Changes for page Git
Last modified by Richard Kreissig on 2025/01/30 12:03
<
edited by Richard Kreissig
on 2025/01/30 12:03
on 2025/01/30 12:03
Change comment:
Update document after refactoring.
Summary
-
Page properties (3 modified, 0 added, 0 removed)
-
Attachments (0 modified, 6 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,0 +1,1 @@ 1 +Projects.Archive.Eclipse Practical (winter term 201213).Tutorials.WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. msp1 +XWiki.stu230980 - Content
-
... ... @@ -6,7 +6,7 @@ 6 6 7 7 8 8 9 -{{toc style="circle" maxLevel="2"/}}9 +{{toc maxLevel="2" style="circle"/}} 10 10 11 11 = Creating Commits = 12 12 ... ... @@ -17,20 +17,20 @@ 17 17 1. ((( 18 18 Configure your name and email address (will be included in all commits you create): 19 19 20 -{{ noformat}}20 +{{code}} 21 21 $ git config --global --add user.name "Your Name" 22 22 $ git config --global --add user.email "<login>@informatik.uni-kiel.de" 23 -{{/ noformat}}23 +{{/code}} 24 24 ))) 25 25 1. ((( 26 26 Create a local repository for the "//Turing Project//": 27 27 28 -{{ noformat}}28 +{{code}} 29 29 $ mkdir turing 30 30 $ cd turing 31 31 $ git init 32 32 Initialized empty Git repository in ~/turing/.git/ 33 -{{/ noformat}}33 +{{/code}} 34 34 35 35 The {{code language="none"}}.git{{/code}} subdirectory contains all history and metadata of the repository. You should not modify it. The {{code language="none"}}turing{{/code}} directory contains the //working copy//, that is the currently checked-out snapshot. You work by modifying your working copy and committing the modifications to the repository (contained in {{code language="none"}}.git{{/code}}). 36 36 ))) ... ... @@ -37,23 +37,23 @@ 37 37 1. ((( 38 38 Add and commit some content: copy [[attach:notes.txt]]{{code language="none"}}{{/code}} to your {{code language="none"}}turing{{/code}} directory. 39 39 40 -{{ noformat}}40 +{{code}} 41 41 $ git add notes.txt 42 42 $ git commit -m "wrote some first notes" 43 43 [master (root-commit) 2e73b34] wrote some first notes 44 44 1 files changed, 5 insertions(+), 0 deletions(-) 45 45 create mode 100644 notes.txt 46 -{{/ noformat}}46 +{{/code}} 47 47 48 48 The file is now stored in the local history of your repository. 49 49 ))) 50 -1. Edit {{code language="none"}}notes.txt{{/code}}: \\50 +1. Edit {{code language="none"}}notes.txt{{/code}}: 51 51 11. Replace "fixed" with "infinite" in line 1. 52 52 11. Replace "... (TODO)" with "a finite state machine" in line 4. 53 53 1. ((( 54 54 View the status of your current working copy: 55 55 56 -{{ noformat}}56 +{{code}} 57 57 $ git status 58 58 # On branch master 59 59 # Changed but not updated: ... ... @@ -63,12 +63,12 @@ 63 63 # modified: notes.txt 64 64 # 65 65 no changes added to commit (use "git add" and/or "git commit -a") 66 -{{/ noformat}}66 +{{/code}} 67 67 ))) 68 68 1. ((( 69 69 Mark the modified file to include it in the next commit, then view the status again and compare with the previous output: 70 70 71 -{{ noformat}}71 +{{code}} 72 72 $ git add notes.txt 73 73 $ git status 74 74 # On branch master ... ... @@ -77,12 +77,12 @@ 77 77 # 78 78 # modified: notes.txt 79 79 # 80 -{{/ noformat}}80 +{{/code}} 81 81 ))) 82 82 1. ((( 83 83 Commit the modified content to your local repository and view the status: 84 84 85 -{{ noformat}}85 +{{code}} 86 86 $ git commit -m "modified tape length, found a controller for tape head" 87 87 [master 52e2d49] modified tape length, found a controller for tape head 88 88 1 files changed, 2 insertions(+), 2 deletions(-) ... ... @@ -89,12 +89,12 @@ 89 89 $ git status 90 90 # On branch master 91 91 nothing to commit (working directory clean) 92 -{{/ noformat}}92 +{{/code}} 93 93 ))) 94 94 95 95 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: 96 96 97 -{{ noformat}}97 +{{code}} 98 98 $ git log 99 99 commit 52e2d4946791c2725015853e5e261ce143c6fe8a 100 100 Author: Miro Spoenemann <msp@informatik.uni-kiel.de> ... ... @@ -126,7 +126,7 @@ 126 126 * Tape head can move left or right 127 127 - * The head is controlled by ... (TODO) 128 128 + * The head is controlled by a finite state machine 129 -{{/ noformat}}129 +{{/code}} 130 130 131 131 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 Mac OSX is [[GitX>>url:http://gitx.frim.nl/||shape="rect"]]). 132 132 ... ... @@ -137,18 +137,18 @@ 137 137 1. ((( 138 138 Create a branch with name //sketches//: 139 139 140 -{{ noformat}}140 +{{code}} 141 141 $ git branch sketches 142 -{{/ noformat}}142 +{{/code}} 143 143 ))) 144 144 1. ((( 145 145 View the list of branches: 146 146 147 -{{ noformat}}147 +{{code}} 148 148 $ git branch 149 149 * master 150 150 sketches 151 -{{/ noformat}}151 +{{/code}} 152 152 153 153 The star reveals that you are still on the old {{code language="none"}}master{{/code}} branch. 154 154 ))) ... ... @@ -155,13 +155,13 @@ 155 155 1. ((( 156 156 Switch to the new branch: 157 157 158 -{{ noformat}}158 +{{code}} 159 159 $ git checkout sketches 160 160 Switched to branch 'sketches' 161 161 $ git branch 162 162 master 163 163 * sketches 164 -{{/ noformat}}164 +{{/code}} 165 165 166 166 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}}. 167 167 ))) ... ... @@ -168,13 +168,13 @@ 168 168 1. ((( 169 169 Download and add the new file [[attach:examples.txt]]{{code language="none"}}{{/code}}: 170 170 171 -{{ noformat}}171 +{{code}} 172 172 $ git add examples.txt 173 173 $ git commit -m "wrote first examples" 174 174 [sketches cd63135] wrote first examples 175 175 1 files changed, 20 insertions(+), 0 deletions(-) 176 176 create mode 100644 examples.txt 177 -{{/ noformat}}177 +{{/code}} 178 178 179 179 Inspecting the commit graph with {{code language="none"}}gitk{{/code}} (or another graphical viewer) you see that the {{code language="none"}}sketches{{/code}} branch now has three commits, while {{code language="none"}}master{{/code}} is still at the second commit. 180 180 ))) ... ... @@ -181,7 +181,7 @@ 181 181 1. ((( 182 182 Merging the {{code language="none"}}sketches{{/code}} branch into {{code language="none"}}master{{/code}} means that all changes that have been made in {{code language="none"}}sketches{{/code}} are also applied to {{code language="none"}}master{{/code}}. In order to perform this merge, we have to check out the {{code language="none"}}master{{/code}} branch first: 183 183 184 -{{ noformat}}184 +{{code}} 185 185 $ git checkout master 186 186 Switched to branch 'master' 187 187 $ git merge sketches ... ... @@ -190,7 +190,7 @@ 190 190 examples.txt | 20 ++++++++++++++++++++ 191 191 1 files changed, 20 insertions(+), 0 deletions(-) 192 192 create mode 100644 examples.txt 193 -{{/ noformat}}193 +{{/code}} 194 194 195 195 This was a //fast-forward// merge: since the {{code language="none"}}master{{/code}} branch was completely contained in the {{code language="none"}}sketches{{/code}} branch, the merge could be done by simply changing the head pointer of {{code language="none"}}master{{/code}} to be the same as the head of {{code language="none"}}sketches{{/code}}. 196 196 ))) ... ... @@ -197,29 +197,29 @@ 197 197 1. ((( 198 198 Now add the line "{{code language="none"}}see some examples in 'examples.txt'{{/code}}" to the file {{code language="none"}}notes.txt{{/code}} and commit this change in the current branch: 199 199 200 -{{ noformat}}200 +{{code}} 201 201 $ git add notes.txt 202 202 $ git commit -m "added reference to the new examples" 203 203 [master a5e244f] added reference to the new examples 204 204 1 files changed, 2 insertions(+), 1 deletions(-) 205 -{{/ noformat}}205 +{{/code}} 206 206 ))) 207 207 1. ((( 208 208 Switch back to the {{code language="none"}}sketches{{/code}} branch and modify it as shown below. Note that the {{code language="none"}}checkout{{/code}} command modifies your working copy, hence you have to update your text editor's content if you opened one of the files. 209 209 210 -{{ noformat}}210 +{{code}} 211 211 $ git checkout sketches 212 212 Switched to branch 'sketches' 213 -{{/ noformat}}213 +{{/code}} 214 214 215 -Add the line "{{code language="none"}}Move one step left:{{/code}}" an dwrite an updated version of the tape with tape headin215 +Add the line "{{code language="none"}}Move one step left:{{/code}}" followed by an accordingly updated version of the tape with tape head at the end of the file {{code language="none"}}examples.txt{{/code}}, then commit. 216 216 217 -{{ noformat}}217 +{{code}} 218 218 $ git add examples.txt 219 219 $ git commit -m "added another example" 220 220 [sketches 55a9cb1] added another example 221 221 1 files changed, 5 insertions(+), 0 deletions(-) 222 -{{/ noformat}}222 +{{/code}} 223 223 224 224 Now your two branches have //diverged//, which means that they cannot be fast-forwarded anymore. 225 225 ))) ... ... @@ -226,24 +226,25 @@ 226 226 1. ((( 227 227 Merge the {{code language="none"}}master{{/code}} branch into {{code language="none"}}sketches{{/code}}: 228 228 229 -{{ noformat}}229 +{{code}} 230 230 $ git merge master 231 231 Merge made by recursive. 232 232 notes.txt | 3 ++- 233 233 1 files changed, 2 insertions(+), 1 deletions(-) 234 -{{/ noformat}}234 +{{/code}} 235 235 236 -Using {{code language="none"}}gitk{{/code}} you can see that a new commit was created that has two parent commits. Such a commit is called //merge// commit and is done automatically when a non-fast-forward merge is applied. 236 +Using {{code language="none"}}gitk{{/code}} you can see that a new commit was created that has two parent commits. Such a commit is called //merge// commit and is done automatically when a non-fast-forward merge is applied. See how both the change to {{code language="none"}}notes.txt{{/code}} done in the {{code language="none"}}master{{/code}} branch and the change to {{code language="none"}}examples.txt{{/code}} done in the {{code language="none"}}sketches{{/code}} branch are now contained in the repository state that results from the merge. 237 237 ))) 238 238 1. ((( 239 239 Add a commit in each of the two branches using the commands you have already learned. 240 + 240 240 1. Check out {{code language="none"}}master{{/code}}. 241 241 1. ((( 242 242 Insert the following line after line 4 of {{code language="none"}}notes.txt{{/code}}: 243 243 244 -{{ noformatnopanel="true"}}245 +{{code nopanel="true"}} 245 245 * The finite state machine has an initial state and one or more final states 246 -{{/ noformat}}247 +{{/code}} 247 247 ))) 248 248 1. Commit the change of {{code language="none"}}notes.txt{{/code}}. 249 249 1. Check out {{code language="none"}}sketches{{/code}} (make sure to refresh your text editor so that {{code language="none"}}notes.txt{{/code}} is reset to its previous state, without the change made above). ... ... @@ -250,9 +250,9 @@ 250 250 1. ((( 251 251 Insert the following line after line 4 of {{code language="none"}}notes.txt{{/code}}: 252 252 253 -{{ noformatnopanel="true"}}254 +{{code nopanel="true"}} 254 254 * Each state transition can trigger head movement and data read/write 255 -{{/ noformat}}256 +{{/code}} 256 256 ))) 257 257 1. Commit the change of {{code language="none"}}notes.txt{{/code}}. 258 258 ))) ... ... @@ -259,12 +259,12 @@ 259 259 1. ((( 260 260 Merge the {{code language="none"}}master{{/code}} branch into the current branch ({{code language="none"}}sketches{{/code}}): 261 261 262 -{{ noformat}}263 +{{code}} 263 263 $ git merge master 264 264 Auto-merging notes.txt 265 265 CONFLICT (content): Merge conflict in notes.txt 266 266 Automatic merge failed; fix conflicts and then commit the result. 267 -{{/ noformat}}268 +{{/code}} 268 268 269 269 As expected, the branches could not be merged automatically, since both branches modified the same line in the same file. 270 270 ))) ... ... @@ -271,7 +271,7 @@ 271 271 1. ((( 272 272 Use the {{code language="none"}}status{{/code}} command to see the list of affected files: 273 273 274 -{{ noformat}}275 +{{code}} 275 275 $ git status 276 276 # On branch sketches 277 277 # Unmerged paths: ... ... @@ -280,18 +280,18 @@ 280 280 # both modified: notes.txt 281 281 # 282 282 no changes added to commit (use "git add" and/or "git commit -a") 283 -{{/ noformat}}284 +{{/code}} 284 284 ))) 285 285 1. ((( 286 286 The modified {{code language="none"}}notes.txt{{/code}} should now contain the following text: 287 287 288 -{{ noformatnopanel="true"}}289 +{{code nopanel="true"}} 289 289 <<<<<<< HEAD 290 290 * Each state transition can trigger head movement and data read/write 291 291 ======= 292 292 * The finite state machine has an initial state and one or more final states 293 293 >>>>>>> master 294 -{{/ noformat}}295 +{{/code}} 295 295 296 296 The upper line is the one committed to {{code language="none"}}sketches{{/code}}, while the lower line was committed to {{code language="none"}}master{{/code}}. You have to resolve the conflict by editing the file. In this case the conflict is resolved by keeping both lines in arbitrary order, that means you should just remove the conflict markers (lines 5, 7, and 9 in {{code language="none"}}notes.txt{{/code}}). 297 297 ))) ... ... @@ -298,7 +298,7 @@ 298 298 1. ((( 299 299 Use the {{code language="none"}}add{{/code}} command to mark {{code language="none"}}notes.txt{{/code}} as resolved. Entering {{code language="none"}}git commit{{/code}} without a message will open a text editor with an automatically created commit message. Just close the editor, and the merge commit is completed: 300 300 301 -{{ noformat}}302 +{{code}} 302 302 $ git commit 303 303 [sketches 21d5ddb] Merge branch 'master' into sketches 304 304 $ git show 21d5ddb ... ... @@ -323,7 +323,7 @@ 323 323 + * Each state transition can trigger head movement and data read/write 324 324 + * The finite state machine has an initial state and one or more final states 325 325 see some examples in 'examples.txt' 326 -{{/ noformat}}327 +{{/code}} 327 327 ))) 328 328 329 329 The {{code language="none"}}gitk{{/code}} tool should now display this graph: ... ... @@ -338,7 +338,7 @@ 338 338 339 339 1. Register to the Gitorious system: [[https:~~/~~/git.rtsys.informatik.uni-kiel.de/>>url:https://git.rtsys.informatik.uni-kiel.de/||shape="rect"]] (use your //Institut für Informatik// login name and email address) 340 340 1. Go to your //Dashboard// → //Manage SSH keys// → //Add SSH key// 341 -1. Copy & paste the content of your public SSH key. \\342 +1. Copy & paste the content of your public SSH key. 342 342 1*. If you don't have an SSH key: use the shell command {{code language="none"}}ssh-keygen{{/code}}, confirm the default destination file {{code language="none"}}~/.ssh/id_rsa{{/code}}, and choose whether to give a passphrase. If you have a passphrase, you need to enter it whenever you use your SSH key for the first time in a session. You can omit the passphrase, but that makes the key less secure. As result, the tool generates a private key {{code language="none"}}~/.ssh/id_rsa{{/code}}, which has to be kept secret, and a public key {{code language="none"}}~/.ssh/id_rsa.pub{{/code}}. 343 343 1. Go to //Projects// → //Create a new project// and call it "personal-<login>", replacing <login> with your own login name. 344 344 1. On the next page, create a repository named "turing" (or select //Add repository// on your project page). ... ... @@ -348,7 +348,7 @@ 348 348 1. ((( 349 349 Transfer your {{code language="none"}}master{{/code}} branch to the new server-side repository. Replace the URL in the following command by the one copied from Gitorious: 350 350 351 -{{ noformat}}352 +{{code}} 352 352 $ git remote add gitorious git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 353 353 $ git push gitorious master 354 354 Counting objects: 15, done. ... ... @@ -359,7 +359,7 @@ 359 359 remote: => Syncing Gitorious... [OK] 360 360 To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 361 361 * [new branch] master -> master 362 -{{/ noformat}}363 +{{/code}} 363 363 364 364 The first command adds a //remote// named "gitorious" to your local repository, which is just a bookmark for the long URL. The second command transfers the {{code language="none"}}master{{/code}} branch to the server, which is called //pushing//. After that is done, reload the Gitorious page in your browser, and you see all changes that are transferred to the server-side repository. 365 365 ))) ... ... @@ -366,7 +366,7 @@ 366 366 1. ((( 367 367 Create a local clone of your remote repository (replace the URL accordingly): 368 368 369 -{{ noformat}}370 +{{code}} 370 370 $ cd .. 371 371 $ git clone git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git turing2 372 372 Initialized empty Git repository in /home/msp/tmp/turing2/.git/ ... ... @@ -376,7 +376,7 @@ 376 376 Receiving objects: 100% (15/15), done. 377 377 Resolving deltas: 100% (3/3), done. 378 378 $ cd turing2 379 -{{/ noformat}}380 +{{/code}} 380 380 381 381 The {{code language="none"}}clone{{/code}} command automatically creates a remote named {{code language="none"}}origin{{/code}} in the new local repository, which is set to the given URL. You will use this second clone to simulate another user with access to the repository. 382 382 ))) ... ... @@ -384,7 +384,7 @@ 384 384 1. ((( 385 385 Push the new commit to the server: 386 386 387 -{{ noformat}}388 +{{code}} 388 388 $ git push 389 389 Counting objects: 5, done. 390 390 Delta compression using up to 16 threads. ... ... @@ -394,11 +394,11 @@ 394 394 remote: => Syncing Gitorious... [OK] 395 395 To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 396 396 8af2d50..1d1577f master -> master 397 -{{/ noformat}}398 +{{/code}} 398 398 399 399 In this case the push command can be used without arguments, which means that it pushes all branches as configured in {{code language="none"}}.git/config{{/code}}: 400 400 401 -{{ noformat}}402 +{{code}} 402 402 $ more .git/config 403 403 [core] 404 404 repositoryformatversion = 0 ... ... @@ -411,7 +411,7 @@ 411 411 [branch "master"] 412 412 remote = origin 413 413 merge = refs/heads/master 414 -{{/ noformat}}415 +{{/code}} 415 415 416 416 Here the branch {{code language="none"}}master{{/code}} is linked with the remote {{code language="none"}}origin{{/code}}, hence {{code language="none"}}git push{{/code}} does the same as {{code language="none"}}git push origin master{{/code}}. 417 417 ))) ... ... @@ -418,16 +418,16 @@ 418 418 1. ((( 419 419 Go back to the original local repository and check out the {{code language="none"}}master{{/code}} branch: 420 420 421 -{{ noformat}}422 +{{code}} 422 422 $ cd ../turing 423 423 $ git checkout master 424 424 Switched to branch 'master' 425 -{{/ noformat}}426 +{{/code}} 426 426 ))) 427 427 1. ((( 428 428 Merge the {{code language="none"}}sketches{{/code}} branch into {{code language="none"}}master{{/code}}: 429 429 430 -{{ noformat}}431 +{{code}} 431 431 $ git merge sketches 432 432 Updating 8af2d50..21d5ddb 433 433 Fast-forward ... ... @@ -434,7 +434,7 @@ 434 434 examples.txt | 5 +++++ 435 435 notes.txt | 1 + 436 436 2 files changed, 6 insertions(+), 0 deletions(-) 437 -{{/ noformat}}438 +{{/code}} 438 438 439 439 Now your local {{code language="none"}}master{{/code}} branch and the one on the server-side repository have diverged 440 440 ))) ... ... @@ -441,7 +441,7 @@ 441 441 1. ((( 442 442 Fetch the server-side changes: 443 443 444 -{{ noformat}}445 +{{code}} 445 445 $ git fetch gitorious 446 446 remote: Counting objects: 5, done. 447 447 remote: Compressing objects: 100% (3/3), done. ... ... @@ -449,16 +449,16 @@ 449 449 Unpacking objects: 100% (3/3), done. 450 450 From git.rtsys.informatik.uni-kiel.de:personal-msp/turing 451 451 8af2d50..1d1577f master -> gitorious/master 452 -{{/ noformat}}453 +{{/code}} 453 453 454 454 Now the change to {{code language="none"}}examples.txt{{/code}} that was previously committed in the {{code language="none"}}turing2{{/code}} repository is stored in a //remote tracking branch// named {{code language="none"}}gitorious/master{{/code}}: 455 455 456 -{{ noformat}}457 +{{code}} 457 457 $ git branch -a 458 458 * master 459 459 sketches 460 460 remotes/gitorious/master 461 -{{/ noformat}}462 +{{/code}} 462 462 463 463 You can analyze the remote tracking branch using the {{code language="none"}}log{{/code}} and {{code language="none"}}show{{/code}} commands. However, you should never directly modify a remote tracking branch. 464 464 ))) ... ... @@ -465,13 +465,13 @@ 465 465 1. ((( 466 466 You can merge the remote changes into your local {{code language="none"}}master{{/code}} branch with the following command: 467 467 468 -{{ noformat}}469 +{{code}} 469 469 $ git merge gitorious/master 470 470 Auto-merging examples.txt 471 471 Merge made by recursive. 472 472 examples.txt | 8 ++++---- 473 473 1 files changed, 4 insertions(+), 4 deletions(-) 474 -{{/ noformat}}475 +{{/code}} 475 475 476 476 Since this combination of {{code language="none"}}fetch{{/code}} and {{code language="none"}}merge{{/code}} is used very often, Git offers a shortcut for it, namely the {{code language="none"}}pull{{/code}} command. In this case the according command would have been {{code language="none"}}git pull gitorious master{{/code}}. 477 477 ))) ... ... @@ -478,7 +478,7 @@ 478 478 1. ((( 479 479 Push the merged branch to the server, and then push the {{code language="none"}}sketches{{/code}} branch, which is not on the server yet: 480 480 481 -{{ noformat}}482 +{{code}} 482 482 $ git push gitorious master 483 483 Counting objects: 23, done. 484 484 Delta compression using up to 16 threads. ... ... @@ -493,19 +493,19 @@ 493 493 remote: => Syncing Gitorious... [OK] 494 494 To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 495 495 * [new branch] sketches -> sketches 496 -{{/ noformat}}497 +{{/code}} 497 497 ))) 498 498 1. ((( 499 499 As next step change your working directory to the second local repository {{code language="none"}}turing2{{/code}}, add the following line to the end of {{code language="none"}}notes.txt{{/code}} in the {{code language="none"}}turing2{{/code}} directory, and commit the change: 500 500 501 -{{ noformatnopanel="true"}}502 +{{code nopanel="true"}} 502 502 TODO: formal definition 503 -{{/ noformat}}504 +{{/code}} 504 504 ))) 505 505 1. ((( 506 506 Trying to push this commit to the server results in the following error message: 507 507 508 -{{ noformat}}509 +{{code}} 509 509 $ git push 510 510 To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 511 511 ! [rejected] master -> master (non-fast-forward) ... ... @@ -513,7 +513,7 @@ 513 513 To prevent you from losing history, non-fast-forward updates were rejected 514 514 Merge the remote changes before pushing again. See the 'Note about 515 515 fast-forwards' section of 'git push --help' for details. 516 -{{/ noformat}}517 +{{/code}} 517 517 518 518 This is because you have modified the branch while working in the original {{code language="none"}}turing{{/code}} repository, and these changes have to be merged with the new commit you have just made for {{code language="none"}}notes.txt{{/code}}. 519 519 ))) ... ... @@ -520,7 +520,7 @@ 520 520 1. ((( 521 521 The solution is to apply the {{code language="none"}}pull{{/code}} command followed by the {{code language="none"}}push{{/code}} command: 522 522 523 -{{ noformat}}524 +{{code}} 524 524 $ git pull 525 525 remote: Counting objects: 23, done. 526 526 remote: Compressing objects: 100% (14/14), done. ... ... @@ -543,7 +543,7 @@ 543 543 remote: => Syncing Gitorious... [OK] 544 544 To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 545 545 957f686..b58ded7 master -> master 546 -{{/ noformat}}547 +{{/code}} 547 547 548 548 While {{code language="none"}}pull{{/code}} performs a {{code language="none"}}fetch{{/code}} and a {{code language="none"}}merge{{/code}}, {{code language="none"}}push{{/code}} transfers the new merged branch to the server. Note that during the merge operation conflicts can occur. In that case you have to resolve them and commit the changes before you can push. When used without parameters like shown above, {{code language="none"}}pull{{/code}} lookes in {{code language="none"}}.git/config{{/code}} to determine which branches to pull from which remotes. 549 549 ))) ... ... @@ -550,11 +550,11 @@ 550 550 1. ((( 551 551 In order to check out the {{code language="none"}}sketches{{/code}} branch locally, which was previously pushed to the server, simply type the following command: 552 552 553 -{{ noformat}}554 +{{code}} 554 554 $ git checkout sketches 555 555 Branch sketches set up to track remote branch sketches from origin. 556 556 Switched to a new branch 'sketches' 557 -{{/ noformat}}558 +{{/code}} 558 558 559 559 This branch can be pushed and pulled with the server in the same way as you did for the {{code language="none"}}master{{/code}} branch. Never check out {{code language="none"}}origin/sketches{{/code}}, since that is a remote tracking branch! 560 560 ))) ... ... @@ -571,7 +571,7 @@ 571 571 572 572 While working on his Machine, Alan Turing has produced a temporary file {{code language="none"}}experiments.tmp{{/code}}, which he does not want to commit in the repository: 573 573 574 -{{ noformat}}575 +{{code}} 575 575 $ git status 576 576 # On branch master 577 577 # Untracked files: ... ... @@ -579,11 +579,11 @@ 579 579 # 580 580 # experiments.tmp 581 581 nothing added to commit but untracked files present (use "git add" to track) 582 -{{/ noformat}}583 +{{/code}} 583 583 584 584 Since the extra mention of that file can make Git's status reports unnecessarily cluttered, Alan wants to ignore it permanently. Help him by adding a {{code language="none"}}.gitignore{{/code}} file to the repository: 585 585 586 -{{ noformat}}587 +{{code}} 587 587 $ echo "*.tmp" > .gitignore 588 588 $ git add .gitignore 589 589 $ git commit -m "added ignore file" ... ... @@ -595,7 +595,7 @@ 595 595 # Your branch is ahead of 'origin/master' by 1 commit. 596 596 # 597 597 nothing to commit (working directory clean) 598 -{{/ noformat}}599 +{{/code}} 599 599 600 600 Now the experiments.tmp{{code language="none"}}{{/code}} file is not considered when viewing the status. You can add arbitrary file name patterns to the {{code language="none"}}.gitignore{{/code}} file; for example it is a good idea to ignore {{code language="none"}}*.class{{/code}}, which are binary files generated for Java projects. 601 601 ... ... @@ -603,7 +603,7 @@ 603 603 604 604 While working on his Machine, Alan Turing has made some changes to notes.txt that he later found out to be nonsense: 605 605 606 -{{ noformat}}607 +{{code}} 607 607 $ git status 608 608 # On branch master 609 609 # Changed but not updated: ... ... @@ -613,29 +613,29 @@ 613 613 # modified: notes.txt 614 614 # 615 615 no changes added to commit (use "git add" and/or "git commit -a") 616 -{{/ noformat}}617 +{{/code}} 617 617 618 618 Help Alan by restoring the last committed state of that file: 619 619 620 -{{ noformat}}621 +{{code}} 621 621 $ git checkout HEAD notes.txt 622 622 $ git status 623 623 # On branch master 624 624 nothing to commit (working directory clean) 625 -{{/ noformat}}626 +{{/code}} 626 626 627 627 Instead of HEAD, which is the last commit on the current branch, you can also name any other branch or commit hash. In that case you would have to commit the change to make it permanent. While resolving conflicts it is possible to use {{code language="none"}}--theirs{{/code}} or {{code language="none"}}--ours{{/code}} instead of HEAD, which replaces the whole content of the respective file by their version (the one on the remote branch) or our version (the one on the current branch). 628 628 629 629 A more brute-force option is using the {{code language="none"}}reset{{/code}} command: 630 630 631 -{{ noformat}}632 +{{code}} 632 632 $ git reset --hard 633 633 HEAD is now at b58ded7 Merge branch 'master' of git.rtsys.informatik.uni-kiel.de:personal-msp/turing 634 -{{/ noformat}}635 +{{/code}} 635 635 636 636 This resets //all// changes to the working copy to the head of the current branch, so use it with caution! However, {{code language="none"}}reset{{/code}} does not remove unstaged files. In order to do that in one command, use {{code language="none"}}clean{{/code}}: 637 637 638 -{{ noformat}}639 +{{code}} 639 639 $ git status 640 640 # On branch master 641 641 # Untracked files: ... ... @@ -647,7 +647,7 @@ 647 647 $ git clean -f 648 648 Removing test1.tmp 649 649 Removing test2.tmp 650 -{{/ noformat}}651 +{{/code}} 651 651 652 652 === Rebasing === 653 653 ... ... @@ -657,7 +657,7 @@ 657 657 658 658 If you want to merge the changes made on the {{code language="none"}}master{{/code}} branch into the {{code language="none"}}sketches{{/code}} branch, the normal way is to use the {{code language="none"}}merge{{/code}} command and create a merge commit. However, the {{code language="none"}}rebase{{/code}} command gives an interesting alternative to that: it reapplies all commits done in the current branch starting from a given reference. 659 659 660 -{{ noformat}}661 +{{code}} 661 661 $ git rebase master 662 662 First, rewinding head to replay your work on top of it... 663 663 Applying: added another example ... ... @@ -665,7 +665,7 @@ 665 665 Using index info to reconstruct a base tree... 666 666 Falling back to patching base and 3-way merge... 667 667 Auto-merging notes.txt 668 -{{/ noformat}}669 +{{/code}} 669 669 670 670 Afterwards the commit graph looks like this: 671 671 ... ... @@ -676,3 +676,33 @@ 676 676 {{warning}} 677 677 Never rebase a branch that is already pushed online! Due to the structural change the rebased branch is no longer compatible with the previous one, and pushing it will fail, since fast-forward merge is not possible. 678 678 {{/warning}} 680 + 681 +=== Tagging === 682 + 683 +Finally Alan Turing has made a great success in the development of his Machine, and he would like to fix that stage as "Milestone 1". Help him by tagging the current state of the project: 684 + 685 +{{code}} 686 +$ git tag milestone1 687 +{{/code}} 688 + 689 +Then the head of the current branch is stored under the name {{code language="none"}}milestone1{{/code}}, so it can be found very easily at later stages of the project: 690 + 691 +{{code}} 692 +$ git tag 693 +milestone1 694 +$ git checkout milestone1 695 +Note: checking out 'milestone1'. 696 + 697 +You are in 'detached HEAD' state. You can look around, make experimental 698 +changes and commit them, and you can discard any commits you make in this 699 +state without impacting any branches by performing another checkout. 700 + 701 +If you want to create a new branch to retain commits you create, you may 702 +do so (now or later) by using -b with the checkout command again. Example: 703 + 704 + git checkout -b new_branch_name 705 + 706 +HEAD is now at 957f686... Merge remote branch 'gitorious/master' 707 +{{/code}} 708 + 709 +Tags can also be loaded to the server using the {{code language="none"}}push{{/code}} command.
- examples.txt
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +192 bytes - Content
-
... ... @@ -1,0 +1,21 @@ 1 +Empty tape with tape head: 2 + 3 + V 4 +---------------- 5 + 6 +Write character "a": 7 + 8 + V 9 +----a----------- 10 + 11 +Move one step right: 12 + 13 + V 14 +----a----------- 15 + 16 +Write character "b": 17 + 18 + V 19 +----ab---------- 20 + 21 +
- notes.txt
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +142 bytes - Content
-
... ... @@ -1,0 +1,6 @@ 1 + * A tape with fixed length 2 + * Tape head can read or write data 3 + * Tape head can move left or right 4 + * The head is controlled by ... (TODO) 5 + 6 +
- turing-graph-01.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +2.9 KB - Content
- turing-graph-02.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +5.4 KB - Content
- turing-graph-03.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +2.5 KB - Content
- turing-graph-04.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.XWikiGuest - Size
-
... ... @@ -1,0 +1,1 @@ 1 +2.1 KB - Content
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -29821 741 +2982081 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/29821 74/Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/2982081/Git