|
@ -134,7 +134,7 @@ |
|
|
|
|
|
|
|
|
## Staging Area |
|
|
## Staging Area |
|
|
|
|
|
|
|
|
### 1. Datei auf den Stand in der Stage zurücksetzen ("git reset --hard "commit_hash") |
|
|
|
|
|
|
|
|
### 1. Datei auf den Stand in der Stage zurücksetzen |
|
|
|
|
|
|
|
|
> $ git reset --hard 888f5299d207085f201038b048e4e1a99503585f |
|
|
> $ git reset --hard 888f5299d207085f201038b048e4e1a99503585f |
|
|
> HEAD is now at 888f529 SCM |
|
|
> HEAD is now at 888f529 SCM |
|
@ -181,4 +181,327 @@ |
|
|
> On branch master |
|
|
> On branch master |
|
|
> nothing to commit, working tree clean |
|
|
> nothing to commit, working tree clean |
|
|
> |
|
|
> |
|
|
|
|
|
## Branching - Anlegen |
|
|
|
|
|
|
|
|
|
|
|
### 1. Zeilen zur Datei "SCM.txt" hinzufügen (nano SCM.txt) und die Änderung comitten. Commit-Message : "main1" |
|
|
|
|
|
> $ git commit -m "master1" |
|
|
|
|
|
> [master 938ffec] master1 |
|
|
|
|
|
> 1 file changed, 2 insertions(+) |
|
|
|
|
|
> create mode 100644 SCM.txt |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 2. Schritt 1 Wiederholen. Commit-Message : "master2" |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "master2" |
|
|
|
|
|
> [master 91cb85a] master2 |
|
|
|
|
|
> 1 file changed, 6 insertions(+), 2 deletions(-) |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 3. Weitere Textdatei "testSCM.txt" anlegen, zur Stage hinzufügen und comitten |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "testSCM hinzugefuegt" |
|
|
|
|
|
> [master 09c235a] testSCM hinzugefuegt |
|
|
|
|
|
> 1 file changed, 0 insertions(+), 0 deletions(-) |
|
|
|
|
|
> create mode 100644 testSCM.txt |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 4. Neuen Branch "test1" erzeugen |
|
|
|
|
|
|
|
|
|
|
|
> $ git branch "test1" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
- und zu diesem wechseln |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout "test1" |
|
|
|
|
|
> Switched to branch 'test1 ' |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 5. Weiter Zeilen in die erste Datei "SCM.txt" einfügen und committen |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test1Commit1" |
|
|
|
|
|
> [test1 2e0aea7] test1Commit1 |
|
|
|
|
|
> 1 file changed, 4 insertions(+) |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 6. Schritt 5 Wiederholen |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test1Commit2" |
|
|
|
|
|
> [test1 539ef41] test1Commit2 |
|
|
|
|
|
> 1 file changed, 4 insertions(+) |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 7. Commit-ID merken |
|
|
|
|
|
|
|
|
|
|
|
> commit 539ef4193e4bf79a6e8d54d46f8506998192a2d8 |
|
|
|
|
|
> test1 539ef41 |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 8. Weitere Zeilen in die zweite Datei "testSCM.txt" einfügen (nano "testSCM") |
|
|
|
|
|
### 9. Änderungen zur git Stage hinzufügen (git add "testSCM.txt") |
|
|
|
|
|
### 10. Aktueller Status des Repository |
|
|
|
|
|
|
|
|
|
|
|
> $ git status |
|
|
|
|
|
> On branch test1 |
|
|
|
|
|
> Changes to be committed: |
|
|
|
|
|
> (use "git restore --staged <file>..." to unstage) |
|
|
|
|
|
> modified: testSCM.txt |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 11. Weitere Zeilen zu "testSCM.txt" hinzufügen |
|
|
|
|
|
|
|
|
|
|
|
## Branching - Zweige wechseln 1 |
|
|
|
|
|
|
|
|
|
|
|
### 1. Zum Branch "master" wechseln |
|
|
|
|
|
> git checkout "master" |
|
|
|
|
|
|
|
|
|
|
|
### 2. Aktueller Status des Repository |
|
|
|
|
|
|
|
|
|
|
|
> $ git status |
|
|
|
|
|
> On branch master |
|
|
|
|
|
> Changes to be committed: |
|
|
|
|
|
> (use "git restore --staged <file>..." to unstage) |
|
|
|
|
|
> modified: testSCM.txt |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
- alt: |
|
|
|
|
|
|
|
|
|
|
|
> $ git status |
|
|
|
|
|
> On branch master |
|
|
|
|
|
> nothing to commit, working tree clean |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 3. Branch wechseln zu "test1" |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout "test1" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 4. Neuen Branch erzeugen "test2" |
|
|
|
|
|
|
|
|
|
|
|
> & git branch "test2" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
## Branching - Zweige Wechseln 2 |
|
|
|
|
|
|
|
|
|
|
|
### 1. Aktuellen Branch auf den Stand des Branches "master" zurücksetzen |
|
|
|
|
|
|
|
|
|
|
|
> $ git reset --hard "2e0aea7" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 2. Status des Repository anzeigen |
|
|
|
|
|
|
|
|
|
|
|
> $ git status |
|
|
|
|
|
> On branch test1 |
|
|
|
|
|
> nothing to commit, working tree clean |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 3. Neue Zeilen in der ersten Datei "SCM.txt" hinzufügen ohne commit |
|
|
|
|
|
|
|
|
|
|
|
### 4. Auf den Branch "test2" wechseln |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout test2 |
|
|
|
|
|
> error: Your local changes to the following files would be overwritten by checkout: |
|
|
|
|
|
> SCM.txt |
|
|
|
|
|
> Please commit your changes or stash them before you switch branches. |
|
|
|
|
|
> Aborting |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 5. Warum schlägt das fehl? |
|
|
|
|
|
|
|
|
|
|
|
- Da die Änderungen an meiner Datei sonst überschrieben werden würden. Man muss zuerst die aktuelle Version der Datei |
|
|
|
|
|
committen oder zur Stash hinzufügen, sonst bricht Git den Versuch, den Branch zu wechseln ab. |
|
|
|
|
|
|
|
|
|
|
|
### 6. Änderungen in die Stage übernehmen |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "master3" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 7. Branch lässt sich wechseln |
|
|
|
|
|
|
|
|
|
|
|
### 8. Wechsel auf den Branch "test2" |
|
|
|
|
|
|
|
|
|
|
|
> git checkout "test2" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 9. Branch "test1" in "test3" umbenennen |
|
|
|
|
|
|
|
|
|
|
|
> $ git branch -m "test1" "test3" |
|
|
|
|
|
|
|
|
|
|
|
## Historie - Anzeigen 1 |
|
|
|
|
|
|
|
|
|
|
|
### 1. Auf Branch "test3" wechseln |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout "test3" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 2. Historie anzeigen lassen |
|
|
|
|
|
|
|
|
|
|
|
> $ git log |
|
|
|
|
|
> commit f68024ec473989ad16ef5c3e60deca3e27da199f (HEAD -> test3, test2) |
|
|
|
|
|
> Author: HV <123> |
|
|
|
|
|
> Date: Sun Nov 19 17:16:37 2023 +0100 |
|
|
|
|
|
> |
|
|
|
|
|
> test1Commit1 |
|
|
|
|
|
> |
|
|
|
|
|
> commit 9380ec4ee992866ca2a06af022d665eed8918ab0 |
|
|
|
|
|
> Author: HV <123> |
|
|
|
|
|
> Date: Sun Nov 19 17:16:15 2023 +0100 |
|
|
|
|
|
> |
|
|
|
|
|
> test1Commit1 |
|
|
|
|
|
> |
|
|
|
|
|
> commit 74660af0098e5ea03e23dc3b611deb26ef6022a4 (master) |
|
|
|
|
|
> Author: HV <123> |
|
|
|
|
|
> Date: Sun Nov 19 17:12:40 2023 +0100 |
|
|
|
|
|
> |
|
|
|
|
|
> testSCM hinzugefuegt |
|
|
|
|
|
> |
|
|
|
|
|
> commit 93adc2aaf180b9e8d7f143d81e460d8692bb2aaa |
|
|
|
|
|
> Author: HV <123> |
|
|
|
|
|
> Date: Sun Nov 19 17:09:48 2023 +0100 |
|
|
|
|
|
> |
|
|
|
|
|
> main2 |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 3. Informationen über den commit |
|
|
|
|
|
- Author, Uhrzeit, Datum, Commit-Message, Commit-Hash |
|
|
|
|
|
|
|
|
|
|
|
### 4. Nur den aktuellen Commit anzeigen (-1) |
|
|
|
|
|
|
|
|
|
|
|
> $ git log -1 |
|
|
|
|
|
> commit f68024ec473989ad16ef5c3e60deca3e27da199f (HEAD -> test3, test2) |
|
|
|
|
|
> Author: HV <123> |
|
|
|
|
|
> Date: Sun Nov 19 17:16:37 2023 +0100 |
|
|
|
|
|
> |
|
|
|
|
|
> test1Commit1 |
|
|
|
|
|
|
|
|
|
|
|
### 5. Vereinfachte Historie |
|
|
|
|
|
|
|
|
|
|
|
> $ git log --oneline |
|
|
|
|
|
> f68024e (HEAD -> test3, test2) test1Commit1 |
|
|
|
|
|
> 9380ec4 test1Commit1 |
|
|
|
|
|
> 74660af (master) testSCM hinzugefuegt |
|
|
|
|
|
> 93adc2a main2 |
|
|
|
|
|
> b93db03 main1 |
|
|
|
|
|
> 979512c SCM |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 6. Informationen über einen Commit |
|
|
|
|
|
|
|
|
|
|
|
- Commit-Message und ID werden ausgegeben |
|
|
|
|
|
|
|
|
|
|
|
### 7. Anzahl der Branches |
|
|
|
|
|
|
|
|
|
|
|
- 3 |
|
|
|
|
|
|
|
|
|
|
|
### 8. Komplette vereinfachte Historie |
|
|
|
|
|
|
|
|
|
|
|
> $ git log --oneline --all |
|
|
|
|
|
> 7a29ba9 (test1) master3 |
|
|
|
|
|
> f68024e (HEAD -> test3, test2) test1Commit1 |
|
|
|
|
|
> 9380ec4 test1Commit1 |
|
|
|
|
|
> 74660af (master) testSCM hinzugefuegt |
|
|
|
|
|
> 93adc2a main2 |
|
|
|
|
|
> b93db03 main1 |
|
|
|
|
|
> 979512c SCM |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 9. Anzahl der Branches in der komplett vereinfachten Historie |
|
|
|
|
|
|
|
|
|
|
|
- 4 |
|
|
|
|
|
|
|
|
|
|
|
### 10. Wo befindet sich die Markierung HEAD |
|
|
|
|
|
|
|
|
|
|
|
- HEAD -> test3, test2 |
|
|
|
|
|
|
|
|
|
|
|
### 11. Auf Branch "test2" wechseln |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout "test2" |
|
|
|
|
|
> Switched to branch "test2" |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 12. Vereinfachte Historie ohne (--all) anzeigen |
|
|
|
|
|
|
|
|
|
|
|
> $ git log --oneline |
|
|
|
|
|
> f68024e (HEAD -> test2, test3) test1Commit1 |
|
|
|
|
|
> 9380ec4 test1Commit1 |
|
|
|
|
|
> 74660af (master) testSCM hinzugefuegt |
|
|
|
|
|
> 93adc2a main2 |
|
|
|
|
|
> b93db03 main1 |
|
|
|
|
|
> 979512c SCM |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 13. Mit Ergebnis von Schritt 7 vergleichen |
|
|
|
|
|
|
|
|
|
|
|
- gleich |
|
|
|
|
|
|
|
|
|
|
|
## Historie Anzeigen 2 |
|
|
|
|
|
|
|
|
|
|
|
### 1. Wechseln auf Branch "test3" |
|
|
|
|
|
|
|
|
|
|
|
> $ git checkout "test3" |
|
|
|
|
|
> Switched to branch 'test3' |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 2. Weitere Zeile in der ersten Datei hinzufügen und comitten |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test3Commit1" |
|
|
|
|
|
> [test3 7074e81] test3Commit1 |
|
|
|
|
|
> 1 file changed, 3 insertions(+) |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 3. Schritt 2 drei Mal wiederholen |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test3Commit2" |
|
|
|
|
|
> [test3 2440b20] test3Commit2 |
|
|
|
|
|
> 1 file changed, 1 insertion(+) |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test3Commit3" |
|
|
|
|
|
> [test3 2e428f4] test3Commit3 |
|
|
|
|
|
> 1 file changed, 1 insertion(+) |
|
|
|
|
|
|
|
|
|
|
|
> $ git commit -m "test3Commit4" |
|
|
|
|
|
> [test3 1ae6afe] test3Commit4 |
|
|
|
|
|
> 1 file changed, 1 insertion(+) |
|
|
|
|
|
|
|
|
|
|
|
### 4. Vereinfachte Historie ohne (--all) |
|
|
|
|
|
|
|
|
|
|
|
> $ git log --oneline |
|
|
|
|
|
> 1ae6afe (HEAD -> test3) test3Commit4 |
|
|
|
|
|
> 2e428f4 test3Commit3 |
|
|
|
|
|
> 2440b20 test3Commit2 |
|
|
|
|
|
> 7074e81 test3Commit1 |
|
|
|
|
|
> f68024e (test2) test1Commit1 |
|
|
|
|
|
> 9380ec4 test1Commit1 |
|
|
|
|
|
> 74660af (master) testSCM hinzugefuegt |
|
|
|
|
|
> 93adc2a main2 |
|
|
|
|
|
> b93db03 main1 |
|
|
|
|
|
> 979512c SCM |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 5. Ergebnis mit Schritt 5 vergleichen |
|
|
|
|
|
|
|
|
|
|
|
- HEAD ist jetzt nur auf "test3" und die neuen commits, wurden in der Historie ergänzt |
|
|
|
|
|
|
|
|
|
|
|
### 6. Komplette verinfachte Historie anzeigen mit (--all) |
|
|
|
|
|
|
|
|
|
|
|
> $ git log --oneline --all |
|
|
|
|
|
> 1ae6afe (HEAD -> test3) test3Commit4 |
|
|
|
|
|
> 2e428f4 test3Commit3 |
|
|
|
|
|
> 2440b20 test3Commit2 |
|
|
|
|
|
> 7074e81 test3Commit1 |
|
|
|
|
|
> 7a29ba9 (test1) master3 |
|
|
|
|
|
> f68024e (test2) test1Commit1 |
|
|
|
|
|
> 9380ec4 test1Commit1 |
|
|
|
|
|
> 74660af (master) testSCM hinzugefuegt |
|
|
|
|
|
> 93adc2a main2 |
|
|
|
|
|
> b93db03 main1 |
|
|
|
|
|
> 979512c SCM |
|
|
|
|
|
> |
|
|
|
|
|
|
|
|
|
|
|
### 7. Mit Schrit 8 vergleichen |
|
|
|
|
|
|
|
|
|
|
|
- HEAD ist jetzt auf "test3", die letzten drei commits wurden ergänzt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|