Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
git_gitea [29/07/2023 - 12:18] – thommie4 | git_gitea [25/04/2025 - 09:09] (aktuell) – [Remote Repos] thommie_netzwissen.de | ||
---|---|---|---|
Zeile 6: | Zeile 6: | ||
* [[https:// | * [[https:// | ||
- | ===== GIT ===== | + | ===== Basisfunktionen & lokale Instanz |
- | + | ||
- | ==== Basisfunktionen & lokale Instanz ==== | + | |
- Arbeitskopie = die echten Dateien, dynamisch | - Arbeitskopie = die echten Dateien, dynamisch | ||
- '' | - '' | ||
- | - '' | + | - '' |
- | - HEAD zeigt immer auf letzten Commit. Ein '' | + | - HEAD zeigt immer auf letzten Commit. Ein '' |
Initialisierung: | Initialisierung: | ||
Zeile 20: | Zeile 18: | ||
git init | git init | ||
git add . | git add . | ||
+ | |||
</ | </ | ||
Zeile 26: | Zeile 25: | ||
'' | '' | ||
+ | Nachträgliches Ändern eines commit Textes | ||
- | ==== Remote Repos: Verknüpfen einer lokalen Instanz mit Remote Instanzen | + | '' |
+ | |||
+ | |||
+ | ===== Remote Repos ===== | ||
" | " | ||
**Kontrolle der Remote Ziele " | **Kontrolle der Remote Ziele " | ||
- | |||
< | < | ||
git remote -v | git remote -v | ||
Zeile 40: | Zeile 42: | ||
upstream | upstream | ||
upstream | upstream | ||
+ | |||
</ | </ | ||
Zeile 45: | Zeile 48: | ||
* origin = persönliches git Repo auf Github. Die kann ein privater Fork eines öffentlichen Repos auf github sein. | * origin = persönliches git Repo auf Github. Die kann ein privater Fork eines öffentlichen Repos auf github sein. | ||
+ | * upstream = Master repo, eigene commits landen dort per Pull Request | ||
- | Anders bei öffentlichen Repos: Öffentliche Repos werden zunächst geforkt, also eine Kopie im eigenen Repo-Speicher als " | + | Aus [[https://www.theserverside.com/ |
- | * upstream = öffentliches Github Repo (z.B. [[https:// | + | ===== Fix upstream |
- | Lokale Instanz: hinzufügen des entfernten | + | If you constantly run into Git's fatal "Current branch has no upstream branch" |
+ | < | ||
+ | This is done by setting the push.autoSetupRemote option in any of [[https:// | ||
+ | |||
+ | ===== How to set push.autoSetupRemote ===== | ||
+ | |||
+ | To tell Git to automatically create new branches in remote repositories upon a push, simply issue the following command: | ||
+ | < | ||
+ | |||
+ | With that configuration setting in place, you'll never have to push with the | ||
+ | < | ||
+ | |||
+ | |||
+ | ===== öffentliche Repos: Kollaboration ===== | ||
+ | |||
+ | Öffentliche Repos werden zunächst geforkt, also eine Kopie im eigenen Repo-Speicher als " | ||
+ | |||
+ | * upstream = öffentliches Github Repo (z.B. [[https:// | ||
+ | |||
+ | Lokale Instanz: hinzufügen des entfernten " | ||
< | < | ||
- | git remote add origin git@github.com: | + | |
+ | git remote add origin git@github.com: | ||
git push -u origin master | git push -u origin master | ||
+ | |||
</ | </ | ||
Zeile 61: | Zeile 86: | ||
< | < | ||
git remote add upstream '' | git remote add upstream '' | ||
+ | |||
</ | </ | ||
- | ==== Authentifizierung über access token ==== | + | ===== Authentifizierung über access token ===== |
< | < | ||
git remote set-url origin https:// | git remote set-url origin https:// | ||
+ | |||
</ | </ | ||
- | ==== Synchronisation lokales Repo mit entfernten ==== | + | ====== Synchronisation lokales Repo mit entfernten |
**pushen** | **pushen** | ||
Zeile 82: | Zeile 109: | ||
'' | '' | ||
- | |||
===== Github: entferntes Repo klonen ===== | ===== Github: entferntes Repo klonen ===== | ||
Zeile 92: | Zeile 118: | ||
'' | '' | ||
- | ====== Update des Fork auf Github | + | ===== Update des Fork auf Github ===== |
Das geht über das **lokale** | Das geht über das **lokale** | ||
Zeile 98: | Zeile 124: | ||
Updates von Upstream holen | Updates von Upstream holen | ||
- | < | + | < |
+ | '' | ||
</ | </ | ||
Zeile 104: | Zeile 131: | ||
Zum master bzw. main wechseln | Zum master bzw. main wechseln | ||
- | < | + | < |
+ | '' | ||
</ | </ | ||
Zeile 110: | Zeile 138: | ||
Master mit upstream mergen | Master mit upstream mergen | ||
- | < | + | < |
+ | '' | ||
</ | </ | ||
Zeile 116: | Zeile 145: | ||
Danach push auf den fork setzen. | Danach push auf den fork setzen. | ||
- | ===== Branches ===== | + | ====== Branches ====== |
+ | |||
+ | Branch erzeugen | ||
+ | |||
+ | < | ||
+ | git checkout -b iss53 | ||
+ | </ | ||
Wo bin ich (aktueller Branch) | Wo bin ich (aktueller Branch) | ||
- | <file> | + | <code> |
- | git show branch | + | git branch |
- | </file> | + | </code> |
- | Alle Branches im Repo zeigen | + | Alle Branches im lokalen und im remote |
< | < | ||
Zeile 134: | Zeile 169: | ||
remotes/ | remotes/ | ||
remotes/ | remotes/ | ||
+ | </ | ||
+ | |||
+ | Nur die remotes zeigen | ||
+ | |||
+ | < | ||
+ | git branch -r | ||
</ | </ | ||
Zeile 160: | Zeile 201: | ||
'' | '' | ||
- | Download eines Branch | + | ===== Download eines bestimmten |
'' | '' | ||
- | danach | + | danach |
'' | '' | ||
+ | Oder: | ||
- | ====== update | + | '' |
+ | |||
+ | ===== Merge & update ===== | ||
'' | '' | ||
Zeile 177: | Zeile 221: | ||
'' | '' | ||
- | ==== Upstream nach fork mergen ==== | + | ===== Upstream nach fork mergen |
Lokales Ziel | Lokales Ziel | ||
- | |||
< | < | ||
+ | |||
git checkout //master// | git checkout //master// | ||
Zeile 195: | Zeile 239: | ||
Danach commit, review und push auf den fork bei Github | Danach commit, review und push auf den fork bei Github | ||
- | ===== Wenn etwas ganz schiefgeht ===== | + | ====== Wenn etwas ganz schiefgeht |
'' | '' | ||
Zeile 220: | Zeile 264: | ||
git config -global core.editor [editor] | git config -global core.editor [editor] | ||
- | </ | + | </ |
|'' | |'' | ||
|'' | |'' | ||
Zeile 232: | Zeile 276: | ||
|'' | |'' | ||
|'' | |'' | ||
- | | | | | + | | |
- | ====== Repo duplizieren | + | ===== Repo duplizieren ===== |
Create a bare clone of the repository. | Create a bare clone of the repository. | ||
- | $ git clone --bare https:// | + | $ git clone –bare [[https:// |
Mirror-push to the new repository. | Mirror-push to the new repository. | ||
- | $ cd old-repository.git | + | $ cd old-repository.git $ git push –mirror |
- | $ git push --mirror https:// | + | |
Remove the temporary local repository you created earlier. | Remove the temporary local repository you created earlier. | ||
- | $ cd .. | + | $ cd .. $ rm -rf old-repository.git |
- | $ rm -rf old-repository.git | + | |
- | ====== Markdown ====== | + | ===== Alte commits entfernen |
- | https:// | + | Commits sichten |
+ | < | ||
- | [[https:// | + | git log --oneline |
- | ===== ASCIIDoc ===== | + | </ |
- | [[https:// | + | Neuen Branch erzeugen, aber ohne history (–orphan) |
- | ==== Admonition ==== | + | < |
+ | git checkout --orphan tem_branch | ||
- | <nowrap> NOTE: An admonition paragraph draws the reader' | + | </code> |
- | Here are the other built-in admonition types: | + | Alle Files hinzufügen |
- | TIP: Pro tip… | + | < |
+ | git add -A | ||
- | IMPORTANT: Don't forget… | + | </ |
- | WARNING: Watch out for… | + | Inital commit im neuen Branch |
- | CAUTION: Ensure that… | + | <code> |
+ | git commit -am " | ||
- | ==== Formatierung ==== | + | </ |
- | < | + | Alten Branch löschen |
- | italic _constrained_ & __un__constrained | + | < |
+ | git branch -D main | ||
- | bold italic *_constrained_* & **__un__** | + | </ |
- | monospace `constrained` & ``un``constrained | + | Den aktuellen Brach umbenennen |
- | monospace bold `*constrained*` & ``**un**``constrained | + | < |
+ | git branch -m main | ||
+ | < | ||
- | monospace italic `_constrained_` & ``__un__``constrained | + | Den " |
- | monospace bold italic `*_constrained_*` & ``**__un__**``constrained | + | <code> |
+ | git push -f origin main | ||
- | Document header | + | </ |
- | < | + | ====== Git mit SSH ====== |
- | My document provides… </ | + | Mehrere ssh Key benutzen: |
- | ==== Überschriften ==== | + | Keys zum agent hinzufügen: |
- | '' | + | < |
+ | < | ||
- | ==== Listen ==== | + | </ |
- | Unordered, basic[[https:// | + | .ssh/config |
- | <file> | + | <code> |
- | * Edgar Allen Poe | + | <font inherit/ |
- | * Sheri S. Tepper | + | |
- | * Bill Bryson | + | |
- | </file> | + | |
- | Unordered, basic (alt)[[https:// | + | #HostName gitea.netzwissen.de |
+ | # IdentityFile ~/.ssh/id_rsa_gitea | ||
+ | # User git | ||
- | < | + | Host 192.168.72.12 |
- | - Edgar Allen Poe | + | IdentityFile ~/.ssh/ |
- | - Sheri S. Tepper | + | User thommie |
- | - Bill Bryson | + | |
- | </file> | + | |
- | Nested Lists: To nest one list within another, indent each item in the sublist by four spaces. You can also nest other elements like paragraphs, blockquotes or code blocks. | + | Host kakariki.netzwissen.de |
+ | HostName kakariki.netzwissen.de | ||
+ | IdentityFile ~/ | ||
+ | </ | ||
- | ===== Gitea ===== | + | Im Repo selbst |
- | Git with a cup of tea - A painless self-hosted Git service | + | .git/config |
- | https://gitea.io/en-us/ | + | < |
+ | < | ||
+ | | ||
+ | bare = false | ||
+ | | ||
+ | ** | ||
+ | [remote " | ||
+ | url = ssh://git@gitea.netzwissen.de: | ||
+ | fetch = +refs/ | ||
+ | [branch " | ||
+ | | ||
+ | merge = refs/heads/main | ||
- | https:// | + | </code> |
- | https:// | + | ====== Gitea ====== |
- | Upgrade script: / | + | Git with a cup of tea - A painless self-hosted Git service |
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | Upgrade script: / | ||