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,19 +1,17 @@ 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 Gitdocumentation 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.Furthermore, the shell command {{code language="none"}}git help{{/code}} lists the most commonly used Git commands, and {{code language="none"}}git help <command>{{/code}} gives very detailed documentation for the specified Git command.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 -=== Contents === 5 +==== Contents ==== 6 6 7 7 8 8 9 -{{toc style="circle" maxLevel=" 2"/}}9 +{{toc style="circle" maxLevel="3"/}} 10 10 11 11 = Creating Commits = 12 12 13 -Most steps of this tutorial are done by typing shell commands. The grey boxes contain the commands you should enter, preceded by a {{code language="none"}}${{/code}} symbol, and followed by their output. While you may copy & paste these commands, some of them may require modifications to adapt them to your own projects. The output will be slightly different for many commands when you enter them, since it also depends on parameters such as the user name and time of execution. 14 - 15 15 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). 16 -1. For Linux, Git is available in its own package. Windows users can install [[msysGit>>url:http://msysgit.github.com/||shape="rect"]]. For Mac X, 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"]].14 +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"]]. 17 17 1. ((( 18 18 Configure your name and email address (will be included in all commits you create): 19 19 ... ... @@ -32,7 +32,7 @@ 32 32 Initialized empty Git repository in ~/turing/.git/ 33 33 {{/noformat}} 34 34 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}}).33 +The {{code language="none"}}.git{{/code}} subdirectory contains all history and metadata of the repository. You should not modify it. 36 36 ))) 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. ... ... @@ -128,11 +128,11 @@ 128 128 + * The head is controlled by a finite state machine 129 129 {{/noformat}} 130 130 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 Xis [[GitX>>url:http://gitx.frim.nl/||shape="rect"]]).129 +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"]]). 132 132 133 133 = Branching and Merging = 134 134 135 -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. In general, you may create as many local branches as you like, since they are simple to use and can be a great tool to structure your work.133 +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. 136 136 137 137 1. ((( 138 138 Create a branch with name //sketches//: ... ... @@ -205,7 +205,7 @@ 205 205 {{/noformat}} 206 206 ))) 207 207 1. ((( 208 -Switch back to the {{code language="none"}}sketches{{/code}} branch and modify itasshownbelow. 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.206 +Switch back to the {{code language="none"}}sketches{{/code}} branch and commit something there. 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 210 {{noformat}} 211 211 $ git checkout sketches ... ... @@ -221,7 +221,7 @@ 221 221 1 files changed, 5 insertions(+), 0 deletions(-) 222 222 {{/noformat}} 223 223 224 -Now your two branches have //diverged//, which means that they cannot be fast-forwarded anymore.222 +Now our two branches have //diverged//, which means that they cannot be fast-forwarded anymore. 225 225 ))) 226 226 1. ((( 227 227 Merge the {{code language="none"}}master{{/code}} branch into {{code language="none"}}sketches{{/code}}: ... ... @@ -245,8 +245,8 @@ 245 245 * The finite state machine has an initial state and one or more final states 246 246 {{/noformat}} 247 247 ))) 248 -1. Commit the change o f{{code language="none"}}notes.txt{{/code}}.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).246 +1. Commit the change to {{code language="none"}}notes.txt{{/code}}. 247 +1. Check out {{code language="none"}}sketches{{/code}} (make sure to refresh your text editor so {{code language="none"}}notes.txt{{/code}} is reset to its previous state, without the change made above). 250 250 1. ((( 251 251 Insert the following line after line 4 of {{code language="none"}}notes.txt{{/code}}: 252 252 ... ... @@ -254,7 +254,7 @@ 254 254 * Each state transition can trigger head movement and data read/write 255 255 {{/noformat}} 256 256 ))) 257 -1. Commit the change o f{{code language="none"}}notes.txt{{/code}}.255 +1. Commit the change to {{code language="none"}}notes.txt{{/code}}. 258 258 ))) 259 259 1. ((( 260 260 Merge the {{code language="none"}}master{{/code}} branch into the current branch ({{code language="none"}}sketches{{/code}}): ... ... @@ -334,345 +334,10 @@ 334 334 335 335 In the previous sections you have worked only with a local repository. The next step is to share this content with a remote repository. Later we will use [[Stash>>url:https://www.atlassian.com/software/stash/overview||shape="rect"]] for repository management, but we need to create group accounts for you first, thus you will use another system called [[Gitorious>>url:https://git.rtsys.informatik.uni-kiel.de/||shape="rect"]] for now. 336 336 337 -Usually it is sufficient to have only one local copy of a Git repository. However, in this tutorial you will create a second copy in order to "simulate" what can happen if two users access the same remote repository: imagine the directories {{code language="none"}}turing{{/code}} and {{code language="none"}}turing2{{/code}} are each managed by a different user. You will simulate the resulting interference by switching your working directory between these two. 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 341 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 -1. Go to //Projects// → //Create a new project// and call it " personal-<login>", replacing <login> with your own login name.339 +1. Go to //Projects// → //Create a new project// and call it "<login>-private", 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). 345 -1. On the repository page, go to //Manage collaborators// → //Add collaborators// and add the user msp. 346 -1. Once you are back on the repository page, copy the URL shown in //Clone & push urls//. 347 -1. Email the copied URL to [[msp@informatik.uni-kiel.de>>mailto:msp@informatik.uni-kiel.de||shape="rect"]]. This will serve as proof for your work on this tutorial. 348 -1. ((( 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 - 351 -{{noformat}} 352 -$ git remote add gitorious git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 353 -$ git push gitorious master 354 -Counting objects: 15, done. 355 -Delta compression using up to 16 threads. 356 -Compressing objects: 100% (13/13), done. 357 -Writing objects: 100% (15/15), 1.54 KiB, done. 358 -Total 15 (delta 3), reused 0 (delta 0) 359 -remote: => Syncing Gitorious... [OK] 360 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 361 - * [new branch] master -> master 362 -{{/noformat}} 363 - 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 -))) 366 -1. ((( 367 -Create a local clone of your remote repository (replace the URL accordingly): 368 - 369 -{{noformat}} 370 -$ cd .. 371 -$ git clone git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git turing2 372 -Initialized empty Git repository in /home/msp/tmp/turing2/.git/ 373 -remote: Counting objects: 15, done. 374 -remote: Compressing objects: 100% (13/13), done. 375 -remote: Total 15 (delta 3), reused 0 (delta 0) 376 -Receiving objects: 100% (15/15), done. 377 -Resolving deltas: 100% (3/3), done. 378 -$ cd turing2 379 -{{/noformat}} 380 - 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 -))) 383 -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. 384 -1. ((( 385 -Push the new commit to the server: 386 - 387 -{{noformat}} 388 -$ git push 389 -Counting objects: 5, done. 390 -Delta compression using up to 16 threads. 391 -Compressing objects: 100% (3/3), done. 392 -Writing objects: 100% (3/3), 362 bytes, done. 393 -Total 3 (delta 1), reused 0 (delta 0) 394 -remote: => Syncing Gitorious... [OK] 395 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 396 - 8af2d50..1d1577f master -> master 397 -{{/noformat}} 398 - 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 - 401 -{{noformat}} 402 -$ more .git/config 403 -[core] 404 - repositoryformatversion = 0 405 - filemode = true 406 - bare = false 407 - logallrefupdates = true 408 -[remote "origin"] 409 - fetch = +refs/heads/*:refs/remotes/origin/* 410 - url = git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 411 -[branch "master"] 412 - remote = origin 413 - merge = refs/heads/master 414 -{{/noformat}} 415 - 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 -))) 418 -1. ((( 419 -Go back to the original local repository and check out the {{code language="none"}}master{{/code}} branch: 420 - 421 -{{noformat}} 422 -$ cd ../turing 423 -$ git checkout master 424 -Switched to branch 'master' 425 -{{/noformat}} 426 -))) 427 -1. ((( 428 -Merge the {{code language="none"}}sketches{{/code}} branch into {{code language="none"}}master{{/code}}: 429 - 430 -{{noformat}} 431 -$ git merge sketches 432 -Updating 8af2d50..21d5ddb 433 -Fast-forward 434 - examples.txt | 5 +++++ 435 - notes.txt | 1 + 436 - 2 files changed, 6 insertions(+), 0 deletions(-) 437 -{{/noformat}} 438 - 439 -Now your local {{code language="none"}}master{{/code}} branch and the one on the server-side repository have diverged 440 -))) 441 -1. ((( 442 -Fetch the server-side changes: 443 - 444 -{{noformat}} 445 -$ git fetch gitorious 446 -remote: Counting objects: 5, done. 447 -remote: Compressing objects: 100% (3/3), done. 448 -remote: Total 3 (delta 1), reused 0 (delta 0) 449 -Unpacking objects: 100% (3/3), done. 450 -From git.rtsys.informatik.uni-kiel.de:personal-msp/turing 451 - 8af2d50..1d1577f master -> gitorious/master 452 -{{/noformat}} 453 - 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 - 456 -{{noformat}} 457 -$ git branch -a 458 -* master 459 - sketches 460 - remotes/gitorious/master 461 -{{/noformat}} 462 - 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 -))) 465 -1. ((( 466 -You can merge the remote changes into your local {{code language="none"}}master{{/code}} branch with the following command: 467 - 468 -{{noformat}} 469 -$ git merge gitorious/master 470 -Auto-merging examples.txt 471 -Merge made by recursive. 472 - examples.txt | 8 ++++---- 473 - 1 files changed, 4 insertions(+), 4 deletions(-) 474 -{{/noformat}} 475 - 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 -))) 478 -1. ((( 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 - 481 -{{noformat}} 482 -$ git push gitorious master 483 -Counting objects: 23, done. 484 -Delta compression using up to 16 threads. 485 -Compressing objects: 100% (14/14), done. 486 -Writing objects: 100% (14/14), 1.65 KiB, done. 487 -Total 14 (delta 4), reused 0 (delta 0) 488 -remote: => Syncing Gitorious... [OK] 489 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 490 - 1d1577f..957f686 master -> master 491 -$ git push gitorious sketches 492 -Total 0 (delta 0), reused 0 (delta 0) 493 -remote: => Syncing Gitorious... [OK] 494 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 495 - * [new branch] sketches -> sketches 496 -{{/noformat}} 497 -))) 498 -1. ((( 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 - 501 -{{noformat nopanel="true"}} 502 -TODO: formal definition 503 -{{/noformat}} 504 -))) 505 -1. ((( 506 -Trying to push this commit to the server results in the following error message: 507 - 508 -{{noformat}} 509 -$ git push 510 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 511 - ! [rejected] master -> master (non-fast-forward) 512 -error: failed to push some refs to 'git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git' 513 -To prevent you from losing history, non-fast-forward updates were rejected 514 -Merge the remote changes before pushing again. See the 'Note about 515 -fast-forwards' section of 'git push --help' for details. 516 -{{/noformat}} 517 - 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 -))) 520 -1. ((( 521 -The solution is to apply the {{code language="none"}}pull{{/code}} command followed by the {{code language="none"}}push{{/code}} command: 522 - 523 -{{noformat}} 524 -$ git pull 525 -remote: Counting objects: 23, done. 526 -remote: Compressing objects: 100% (14/14), done. 527 -remote: Total 14 (delta 4), reused 0 (delta 0) 528 -Unpacking objects: 100% (14/14), done. 529 -From git.rtsys.informatik.uni-kiel.de:personal-msp/turing 530 - 1d1577f..957f686 master -> origin/master 531 - * [new branch] sketches -> origin/sketches 532 -Auto-merging notes.txt 533 -Merge made by recursive. 534 - examples.txt | 5 +++++ 535 - notes.txt | 1 + 536 - 2 files changed, 6 insertions(+), 0 deletions(-) 537 -$ git push 538 -Counting objects: 10, done. 539 -Delta compression using up to 16 threads. 540 -Compressing objects: 100% (6/6), done. 541 -Writing objects: 100% (6/6), 673 bytes, done. 542 -Total 6 (delta 2), reused 0 (delta 0) 543 -remote: => Syncing Gitorious... [OK] 544 -To git@git.rtsys.informatik.uni-kiel.de:personal-msp/turing.git 545 - 957f686..b58ded7 master -> master 546 -{{/noformat}} 547 - 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 -))) 550 -1. ((( 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 - 553 -{{noformat}} 554 -$ git checkout sketches 555 -Branch sketches set up to track remote branch sketches from origin. 556 -Switched to a new branch 'sketches' 557 -{{/noformat}} 558 - 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 -))) 561 - 562 -The {{code language="none"}}master{{/code}} branch should look like this: 563 - 564 -[[image:attach:turing-graph-02.png]] 565 - 566 -= Other Useful Commands = 567 - 568 -This section contains optional steps that you don't need to push online, but can be useful for you to learn. 569 - 570 -=== Ignoring Files === 571 - 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 - 574 -{{noformat}} 575 -$ git status 576 -# On branch master 577 -# Untracked files: 578 -# (use "git add <file>..." to include in what will be committed) 579 -# 580 -# experiments.tmp 581 -nothing added to commit but untracked files present (use "git add" to track) 582 -{{/noformat}} 583 - 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 - 586 -{{noformat}} 587 -$ echo "*.tmp" > .gitignore 588 -$ git add .gitignore 589 -$ git commit -m "added ignore file" 590 -[master 738ce4c] added ignore file 591 - 1 files changed, 1 insertions(+), 0 deletions(-) 592 - create mode 100644 .gitignore 593 -$ git status 594 -# On branch master 595 -# Your branch is ahead of 'origin/master' by 1 commit. 596 -# 597 -nothing to commit (working directory clean) 598 -{{/noformat}} 599 - 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 - 602 -=== Discarding Changes === 603 - 604 -While working on his Machine, Alan Turing has made some changes to notes.txt that he later found out to be nonsense: 605 - 606 -{{noformat}} 607 -$ git status 608 -# On branch master 609 -# Changed but not updated: 610 -# (use "git add <file>..." to update what will be committed) 611 -# (use "git checkout -- <file>..." to discard changes in working directory) 612 -# 613 -# modified: notes.txt 614 -# 615 -no changes added to commit (use "git add" and/or "git commit -a") 616 -{{/noformat}} 617 - 618 -Help Alan by restoring the last committed state of that file: 619 - 620 -{{noformat}} 621 -$ git checkout HEAD notes.txt 622 -$ git status 623 -# On branch master 624 -nothing to commit (working directory clean) 625 -{{/noformat}} 626 - 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 - 629 -A more brute-force option is using the {{code language="none"}}reset{{/code}} command: 630 - 631 -{{noformat}} 632 -$ git reset --hard 633 -HEAD is now at b58ded7 Merge branch 'master' of git.rtsys.informatik.uni-kiel.de:personal-msp/turing 634 -{{/noformat}} 635 - 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 - 638 -{{noformat}} 639 -$ git status 640 -# On branch master 641 -# Untracked files: 642 -# (use "git add <file>..." to include in what will be committed) 643 -# 644 -# test1.tmp 645 -# test2.tmp 646 -nothing added to commit but untracked files present (use "git add" to track) 647 -$ git clean -f 648 -Removing test1.tmp 649 -Removing test2.tmp 650 -{{/noformat}} 651 - 652 -=== Rebasing === 653 - 654 -Consider the following situation: 655 - 656 -[[image:attach:turing-graph-03.png]] 657 - 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 - 660 -{{noformat}} 661 -$ git rebase master 662 -First, rewinding head to replay your work on top of it... 663 -Applying: added another example 664 -Applying: state transitions 665 -Using index info to reconstruct a base tree... 666 -Falling back to patching base and 3-way merge... 667 -Auto-merging notes.txt 668 -{{/noformat}} 669 - 670 -Afterwards the commit graph looks like this: 671 - 672 -[[image:attach:turing-graph-04.png]] 673 - 674 -The two commits made in {{code language="none"}}sketches{{/code}} are reapplied starting from the head of the {{code language="none"}}master{{/code}} branch. The resulting structure of commits is much cleaner than before. It is even possible to squeeze multiple commits into one using {{code language="none"}}rebase{{/code}}. 675 - 676 -{{warning}} 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 -{{/warning}} 341 +1. Once you are on the repository page, copy the URL shown in //Clone & push urls//.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -29821 671 +2982148 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/29821 67/Git1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/2982148/Git