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
-
... ... @@ -336,6 +336,225 @@ 336 336 1. Go to your //Dashboard// → //Manage SSH keys// → //Add SSH key// 337 337 1. Copy & paste the content of your public SSH key.\\ 338 338 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}}. 339 -1. Go to //Projects// → //Create a new project// and call it "<login> -private", replacing <login> with your own login name.339 +1. Go to //Projects// → //Create a new project// and call it "personal-<login>", replacing <login> with your own login name. 340 340 1. On the next page, create a repository named "turing" (or select //Add repository// on your project page). 341 341 1. Once you are on the repository page, copy the URL shown in //Clone & push urls//. 342 +1. ((( 343 +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: 344 + 345 +{{noformat}} 346 +$ git remote add gitorious git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 347 +$ git push gitorious master 348 +Counting objects: 15, done. 349 +Delta compression using up to 16 threads. 350 +Compressing objects: 100% (13/13), done. 351 +Writing objects: 100% (15/15), 1.54 KiB, done. 352 +Total 15 (delta 3), reused 0 (delta 0) 353 +remote: => Syncing Gitorious... [OK] 354 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 355 + * [new branch] master -> master 356 +{{/noformat}} 357 + 358 +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. 359 +))) 360 +1. ((( 361 +Create a local clone of your remote repository (replace the URL accordingly): 362 + 363 +{{noformat}} 364 +$ cd .. 365 +$ git clone git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git turing2 366 +Initialized empty Git repository in /home/msp/tmp/turing2/.git/ 367 +remote: Counting objects: 15, done. 368 +remote: Compressing objects: 100% (13/13), done. 369 +remote: Total 15 (delta 3), reused 0 (delta 0) 370 +Receiving objects: 100% (15/15), done. 371 +Resolving deltas: 100% (3/3), done. 372 +$ cd turing2 373 +{{/noformat}} 374 + 375 +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. 376 +))) 377 +1. Edit the file {{code language="none"}}examples.txt{{/code}} in the new clone ({{code language="none"}}turing2{{/code}}): replace {{code language="none"}}"a"{{/code}} in line 6 by {{code language="none"}}"c"{{/code}} and correct the tape representations in lines 9, 14, and 19 accordingly. Commit the change. 378 +1. ((( 379 +Push the new commit to the server: 380 + 381 +{{noformat}} 382 +$ git push 383 +Counting objects: 5, done. 384 +Delta compression using up to 16 threads. 385 +Compressing objects: 100% (3/3), done. 386 +Writing objects: 100% (3/3), 362 bytes, done. 387 +Total 3 (delta 1), reused 0 (delta 0) 388 +remote: => Syncing Gitorious... [OK] 389 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 390 + 8af2d50..1d1577f master -> master 391 +{{/noformat}} 392 + 393 +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}}: 394 + 395 +{{noformat}} 396 +$ more .git/config 397 +[core] 398 + repositoryformatversion = 0 399 + filemode = true 400 + bare = false 401 + logallrefupdates = true 402 +[remote "origin"] 403 + fetch = +refs/heads/*:refs/remotes/origin/* 404 + url = git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 405 +[branch "master"] 406 + remote = origin 407 + merge = refs/heads/master 408 +{{/noformat}} 409 + 410 +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}}. 411 +))) 412 +1. ((( 413 +Go back to the original local repository and check out the {{code language="none"}}master{{/code}} branch: 414 + 415 +{{noformat}} 416 +$ cd ../turing 417 +$ git checkout master 418 +Switched to branch 'master' 419 +{{/noformat}} 420 +))) 421 +1. ((( 422 +Merge the {{code language="none"}}sketches{{/code}} branch into {{code language="none"}}master{{/code}}: 423 + 424 +{{noformat}} 425 +$ git merge sketches 426 +Updating 8af2d50..21d5ddb 427 +Fast-forward 428 + examples.txt | 5 +++++ 429 + notes.txt | 1 + 430 + 2 files changed, 6 insertions(+), 0 deletions(-) 431 +{{/noformat}} 432 + 433 +Now your local {{code language="none"}}master{{/code}} branch and the one on the server-side repository have diverged 434 +))) 435 +1. ((( 436 +Fetch the server-side changes: 437 + 438 +{{noformat}} 439 +$ git fetch gitorious 440 +remote: Counting objects: 5, done. 441 +remote: Compressing objects: 100% (3/3), done. 442 +remote: Total 3 (delta 1), reused 0 (delta 0) 443 +Unpacking objects: 100% (3/3), done. 444 +From git.rtsys.informatik.uni-kiel.de:personal-msp/turing 445 + 8af2d50..1d1577f master -> gitorious/master 446 +{{/noformat}} 447 + 448 +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}}: 449 + 450 +{{noformat}} 451 +$ git branch -a 452 +* master 453 + sketches 454 + remotes/gitorious/master 455 +{{/noformat}} 456 + 457 +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. 458 +))) 459 +1. ((( 460 +You can merge the remote changes into your local {{code language="none"}}master{{/code}} branch with the following command: 461 + 462 +{{noformat}} 463 +$ git merge gitorious/master 464 +Auto-merging examples.txt 465 +Merge made by recursive. 466 + examples.txt | 8 ++++---- 467 + 1 files changed, 4 insertions(+), 4 deletions(-) 468 +{{/noformat}} 469 + 470 +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}}. 471 +))) 472 +1. ((( 473 +Push the merged branch to the server, and then push the {{code language="none"}}sketches{{/code}} branch, which is not on the server yet: 474 + 475 +{{noformat}} 476 +$ git push gitorious master 477 +Counting objects: 23, done. 478 +Delta compression using up to 16 threads. 479 +Compressing objects: 100% (14/14), done. 480 +Writing objects: 100% (14/14), 1.65 KiB, done. 481 +Total 14 (delta 4), reused 0 (delta 0) 482 +remote: => Syncing Gitorious... [OK] 483 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 484 + 1d1577f..957f686 master -> master 485 +$ git push gitorious sketches 486 +Total 0 (delta 0), reused 0 (delta 0) 487 +remote: => Syncing Gitorious... [OK] 488 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 489 + * [new branch] sketches -> sketches 490 +{{/noformat}} 491 +))) 492 +1. ((( 493 +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: 494 + 495 +{{noformat nopanel="true"}} 496 +TODO: formal definition 497 +{{/noformat}} 498 +))) 499 +1. ((( 500 +Trying to push this commit to the server results in the following error message: 501 + 502 +{{noformat}} 503 +$ git push 504 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 505 + ! [rejected] master -> master (non-fast-forward) 506 +error: failed to push some refs to 'git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git' 507 +To prevent you from losing history, non-fast-forward updates were rejected 508 +Merge the remote changes before pushing again. See the 'Note about 509 +fast-forwards' section of 'git push --help' for details. 510 +{{/noformat}} 511 + 512 +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}}. 513 +))) 514 +1. ((( 515 +The solution is to apply the {{code language="none"}}pull{{/code}} command followed by the {{code language="none"}}push{{/code}} command: 516 + 517 +{{noformat}} 518 +$ git pull 519 +remote: Counting objects: 23, done. 520 +remote: Compressing objects: 100% (14/14), done. 521 +remote: Total 14 (delta 4), reused 0 (delta 0) 522 +Unpacking objects: 100% (14/14), done. 523 +From git.rtsys.informatik.uni-kiel.de:personal-msp/turing 524 + 1d1577f..957f686 master -> origin/master 525 + * [new branch] sketches -> origin/sketches 526 +Auto-merging notes.txt 527 +Merge made by recursive. 528 + examples.txt | 5 +++++ 529 + notes.txt | 1 + 530 + 2 files changed, 6 insertions(+), 0 deletions(-) 531 +$ git push 532 +Counting objects: 10, done. 533 +Delta compression using up to 16 threads. 534 +Compressing objects: 100% (6/6), done. 535 +Writing objects: 100% (6/6), 673 bytes, done. 536 +Total 6 (delta 2), reused 0 (delta 0) 537 +remote: => Syncing Gitorious... [OK] 538 +To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 539 + 957f686..b58ded7 master -> master 540 +{{/noformat}} 541 + 542 +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. 543 +))) 544 +1. ((( 545 +In order to check out the {{code language="none"}}sketches{{/code}} branch, which was previously pushed to the server, simply type the following command: 546 + 547 +{{noformat}} 548 +$ git checkout sketches 549 +Branch sketches set up to track remote branch sketches from origin. 550 +Switched to a new branch 'sketches' 551 +{{/noformat}} 552 + 553 +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. 554 +))) 555 + 556 +The {{code language="none"}}master{{/code}} branch should look like this: 557 + 558 +[[image:attach:turing-graph-02.png]] 559 + 560 +
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -29821 481 +2982151 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/29821 48/Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/2982151/Git