git
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git [2022/05/16 15:54] – [AvrilServer on kalaschnikow2017 (Web application)] kalaschnikow | git [2023/02/09 16:35] (current) – kalaschnikow | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Git ====== | ||
| + | Some information about git. | ||
| + | ===== Some useful commands ===== | ||
| + | |||
| + | ==== Working with branches ==== | ||
| + | [[https:// | ||
| + | |||
| + | The following is a short citation from it. | ||
| + | |||
| + | Nehmen wir an, ein Fehler wurde gemeldet und ihr wollt diesen Beheben. Ihr erstellt euch für euren Bugfix zuerst einen neuen, lokalen Branch „bugfix“, | ||
| + | <code bash> | ||
| + | git checkout -b bugfix master | ||
| + | </ | ||
| + | Wenn ihr jetzt „git“ Status aufruft, wird euch angezeigt, dass ihr euch auf dem „bugfix“-Versionszweig befindet. Ihr könnt jetzt eure Änderungen am Code durchführen, | ||
| + | |||
| + | <code bash> | ||
| + | git add . | ||
| + | git commit -m "Fixes bug xy" | ||
| + | </ | ||
| + | Falls ihr euren Branch auch anderen Entwicklern auf dem Server bereitstellen wollt, könnt ihr optional ein | ||
| + | |||
| + | <code bash> | ||
| + | git push -u origin bugfix | ||
| + | </ | ||
| + | ausführen. Wenn ihr alleine an dem Bugfix arbeitet, ist das aber nicht nötig. In dem Fall bleibt euer Branch | ||
| + | lokal auf dem Rechner. Der Commit auf dem bugfix-Branch ist erstellt – jetzt wird wieder in den master-Branch gewechselt: | ||
| + | |||
| + | <code bash> | ||
| + | git checkout master | ||
| + | </ | ||
| + | … und die Änderungen aus eurem bugfix-Branch werden darauf angewendet: | ||
| + | |||
| + | <code bash> | ||
| + | git merge bugfix | ||
| + | </ | ||
| + | Zum Schluss noch ein | ||
| + | |||
| + | <code bash> | ||
| + | git push | ||
| + | </ | ||
| + | … um den aktualisierten master-Branch auf dem Server zu aktualisieren. Euer bugfix-Branch wird nun nicht mehr benötigt und kann gelöscht werden: | ||
| + | |||
| + | <code bash> | ||
| + | git branch -d bugfix | ||
| + | </ | ||
| + | |||
| + | === Allgemeiner Workflow === | ||
| + | |||
| + | Während der Entwicklungsarbeit wird euer Workflow meistens in etwa so aussehen: | ||
| + | |||
| + | 1. Aktuellen master-Branch vom Server downloaden (vorher mit git status sicherstellen, | ||
| + | **git pull** | ||
| + | |||
| + | 2. Einen neuen Branch für das kommende Feature anlegen: | ||
| + | **git checkout -b meinfeature master** | ||
| + | |||
| + | 3. Änderungen am Code durchführen | ||
| + | |||
| + | 4. Geänderte und neue Dateien stagen: | ||
| + | **git add .** | ||
| + | |||
| + | 5. Änderungen committen: | ||
| + | **git commit -m „Changes xyz“** | ||
| + | |||
| + | 6. Jetzt den Branch auf den Server laden, wenn gewünscht: | ||
| + | **git push -u origin meinfeature** | ||
| + | |||
| + | 7. … oder direkt in dem master wechseln: | ||
| + | **git checkout master** | ||
| + | |||
| + | 8. (nochmals aktuellen Code ziehen – zur Sicherheit)\\ | ||
| + | **git pull** | ||
| + | |||
| + | 9. Eigenen Code mit master zusammenführen: | ||
| + | **git merge meinfeature** | ||
| + | |||
| + | 10. Nicht mehr benötigten Branch löschen: | ||
| + | **git branch -d meinfeature** | ||
| + | |||
| + | 11. Aktualisierten master auf den Server pushen: | ||
| + | **git push** | ||
| + | |||
| + | 12. Fertig :) | ||
| + | ==== Host remote repository on local file system ==== | ||
| + | |||
| + | Create local repository: | ||
| + | <code bash> | ||
| + | cd myworkspace | ||
| + | git init | ||
| + | </ | ||
| + | |||
| + | Init remote (bare) repo | ||
| + | <code bash> | ||
| + | cd repos # change to whichever directory you like | ||
| + | git init --bare myrepo.git | ||
| + | </ | ||
| + | |||
| + | Add remote origin to local repo | ||
| + | <code bash> | ||
| + | cd myworkspace # go back to local workspace | ||
| + | git remote add origin / | ||
| + | </ | ||
| + | |||
| + | Neue Repo auf der Diskstation anlegen: | ||
| + | <code bash> | ||
| + | ssh admin@diskstation | ||
| + | cd / | ||
| + | git init --bare --shared myrepo.git | ||
| + | </ | ||
| + | or (check first the first!) | ||
| + | <code bash> | ||
| + | ssh admin@diskstation | ||
| + | cd / | ||
| + | mkdir myrepo.git | ||
| + | cd myrepo.git | ||
| + | git init --bare --shared | ||
| + | </ | ||
| + | |||
| + | === Copy local repo to server as bare repo === | ||
| + | |||
| + | <code bash> | ||
| + | git clone --bare myprojectrepo myprojectrepo.git | ||
| + | cp -R myprojectrepo / | ||
| + | </ | ||
| + | |||
| + | ==== Merging vs. Rebasing ==== | ||
| + | A short summary of [[https:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===== Git GUI Clients ===== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ==== GitHub Desktop ==== | ||
| + | |||
| + | https:// | ||
| + | ==== Eclipse integration EGit ==== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | ===== Links ===== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | http:// | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | ==== Workflows ==== | ||
| + | |||
| + | [[http:// | ||
| + | [[https:// | ||
| + | [[http:// | ||
| + | [[https:// | ||
| + | |||
| + | |||
| + | ===== Link lists ===== | ||
| + | http:// | ||
| + | |||
| + | ====== My Repos ====== | ||
| + | |||
| + | ===== AvrilServer on kalaschnikow2017 (Web application) ===== | ||
| + | |||
| + | origin | ||
| + | |||
| + | ssh:/ / | ||
| + | |||
| + | |||
| + | |||
| + | ===== avril on kalaschnikow2017 (Android app) ===== | ||
| + | |||
| + | origin | ||
| + | |||
| + | ssh:/ / | ||
| + | |||
| + | ===== jrserver on kalaschnikow2017 | ||
| + | |||
| + | origin | ||
| + | |||
| + | http:// | ||
