git_gitea

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
git_gitea [09/10/2023 - 07:45] thommie4git_gitea [05/03/2024 - 10:52] (aktuell) – Externe Bearbeitung 127.0.0.1
Zeile 1: Zeile 1:
 ====== GIT und GITHUB Basisdoku ====== ====== GIT und GITHUB Basisdoku ======
- 
  
   * [[https://rogerdudler.github.io/git-guide/index.de.html|https://rogerdudler.github.io/git-guide/index.de.html]]   * [[https://rogerdudler.github.io/git-guide/index.de.html|https://rogerdudler.github.io/git-guide/index.de.html]]
Zeile 7: Zeile 6:
   * [[https://www.thomas-krenn.com/de/wiki/Git_Grundbefehle|https://www.thomas-krenn.com/de/wiki/Git_Grundbefehle]]   * [[https://www.thomas-krenn.com/de/wiki/Git_Grundbefehle|https://www.thomas-krenn.com/de/wiki/Git_Grundbefehle]]
  
-====== Basisfunktionen & lokale Instanz ======+===== Basisfunktionen & lokale Instanz =====
  
   - Arbeitskopie = die echten Dateien, dynamisch   - Arbeitskopie = die echten Dateien, dynamisch
   - ''git add''  addiert den aktuellen Datenstand in den Index ("Stage")   - ''git add''  addiert den aktuellen Datenstand in den Index ("Stage")
-  - ''git coomit'' trägt den Datenstand in den HEAD ein (standardmässig in den "main" Branch) +  - ''git coomit''  trägt den Datenstand in den HEAD ein (standardmässig in den "main" Branch) 
-  - HEAD zeigt immer auf letzten Commit. Ein ''git commit -m "Commit-Nachricht"''  übernimmt den Status nach HEAD. +  - HEAD zeigt immer auf letzten Commit. Ein ''git commit -m "Commit-Nachricht"''  übernimmt den Status nach HEAD.
  
 Initialisierung: leeres Repository erzeugen und die darin vorhandenen Dateien in den lokalen git Index aufnehmen Initialisierung: leeres Repository erzeugen und die darin vorhandenen Dateien in den lokalen git Index aufnehmen
- 
 <code> <code>
 +
 git init git init
 git add . git add .
 +
 </code> </code>
  
Zeile 25: Zeile 25:
 ''git commit -m "Commit-Nachricht"'' ''git commit -m "Commit-Nachricht"''
  
 +===== Remote Repos: Verknüpfen einer lokalen Instanz mit Remote Instanzen =====
  
-====== Remote Repos: Verknüpfen einer lokalen Instanz mit Remote Instanzen ====== +"origin" ist das **eigene**  Standard-remote-Repo (z.B. github, gitea). "upstream" ist das Team-Repo. Änderungen aus "origin" werden mit einem Pull Request für das "upstream" Repo angeboten. Von dort wird die Änderungen per "pull" geholt, falls sie akzeptiert wird.
- +
- +
-"origin" ist das **eigene** Standard-remote-Repo (z.B. github, gitea). "upstream" ist das Team-Repo. Änderungen aus "origin" werden mit einem Pull Request für das "upstream" Repo angeboten. Von dort wird die Änderungen per "pull" geholt, falls sie akzeptiert wird.+
  
 **Kontrolle der Remote Ziele "origin" und "upstream"** **Kontrolle der Remote Ziele "origin" und "upstream"**
Zeile 40: Zeile 38:
 upstream        git@github.com:owncloud/docs.git (fetch) upstream        git@github.com:owncloud/docs.git (fetch)
 upstream        git@github.com:owncloud/docs.git (push) upstream        git@github.com:owncloud/docs.git (push)
 +
 </code> </code>
  
Zeile 46: Zeile 45:
   * 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.
  
-Anders bei öffentlichen Repos: Öffentliche Repos werden zunächst geforkt, also eine Kopie im eigenen Repo-Speicher als "origin" angelegt. Lokale Änderungen werden zuerst nach origin übertragen. Danach werden sie per pull request (PR) zur Übernahme nach  upstream "angemeldet".+Anders bei öffentlichen Repos: Öffentliche Repos werden zunächst geforkt, also eine Kopie im eigenen Repo-Speicher als "origin" angelegt. Lokale Änderungen werden zuerst nach origin übertragen. Danach werden sie per pull request (PR) zur Übernahme nach upstream "angemeldet".
  
-  * upstream = öffentliches Github Repo (z.B. [[https://github.com/owncloud/core|https://github.com/owncloud/core]]). +  * upstream = öffentliches Github Repo (z.B. [[https://github.com/owncloud/core|https://github.com/owncloud/core]]).
  
 Lokale Instanz: hinzufügen des entfernten "origin" Lokale Instanz: hinzufügen des entfernten "origin"
- 
 <code> <code>
-git remote add origin git@github.com:thommierother/oc-theme-nw2.git + 
 +git remote add origin git@github.com:thommierother/oc-theme-nw2.git
 git push -u origin master git push -u origin master
 +
 </code> </code>
  
Zeile 61: Zeile 61:
 <code> <code>
 git remote add upstream ''git@github.com:https://github.com/owncloud/docs.git'' git remote add upstream ''git@github.com:https://github.com/owncloud/docs.git''
 +
 </code> </code>
  
 ===== Authentifizierung über access token ===== ===== Authentifizierung über access token =====
- 
  
 <code> <code>
 git remote set-url origin https://username:token@github.com/username/repository.git git remote set-url origin https://username:token@github.com/username/repository.git
-</code> 
  
-===== Synchronisation lokales Repo mit entfernten =====+</code>
  
 +====== Synchronisation lokales Repo mit entfernten ======
  
 **pushen** **pushen**
Zeile 84: Zeile 84:
  
 ''git fetch upstream ''Änderungen von upstream abholen ''git fetch upstream ''Änderungen von upstream abholen
- 
  
 ===== Github: entferntes Repo klonen ===== ===== Github: entferntes Repo klonen =====
- 
  
 Lokale Kopie des aktuellen Arbeitsstandes auf github anlegen Lokale Kopie des aktuellen Arbeitsstandes auf github anlegen
Zeile 101: Zeile 99:
 Updates von Upstream holen Updates von Upstream holen
  
-<code>''$ git fetch upstream''+<code> 
 +''$ git fetch upstream''
  
 </code> </code>
Zeile 107: Zeile 106:
 Zum master bzw. main wechseln Zum master bzw. main wechseln
  
-<code>''git checkout master''+<code> 
 +''git checkout master''
  
 </code> </code>
Zeile 113: Zeile 113:
 Master mit upstream mergen Master mit upstream mergen
  
-<code>''git merge upstream/master''+<code> 
 +''git merge upstream/master''
  
 </code> </code>
Zeile 120: Zeile 121:
  
 ====== Branches ====== ====== Branches ======
- 
  
 Wo bin ich (aktueller Branch) Wo bin ich (aktueller Branch)
Zeile 126: Zeile 126:
 <file> <file>
 git branch git branch
 +
 </file> </file>
  
Zeile 138: Zeile 139:
   remotes/origin/main   remotes/origin/main
   remotes/origin/master   remotes/origin/master
 +
 </code> </code>
  
Zeile 144: Zeile 146:
 <code> <code>
 git checkout master git checkout master
 +
 </code> </code>
  
Zeile 165: Zeile 168:
  
 ===== Download eines bestimmten Branch ===== ===== Download eines bestimmten Branch =====
- 
  
 ''git checkout -b workstation-16.2.1 origin/workstation-16.2.1'' ''git checkout -b workstation-16.2.1 origin/workstation-16.2.1''
  
-danach +danach
  
 ''git pull'' ''git pull''
Zeile 175: Zeile 177:
 Oder: Oder:
  
-''git clone -b workstation-17.0.2 https://github.com/mkubecek/vmware-host-modules.git''+''git clone -b workstation-17.0.2 [[https://github.com/mkubecek/vmware-host-modules.git|https://github.com/mkubecek/vmware-host-modules.git]]''
  
-====== Merge & update ======+===== Merge & update =====
  
 ''git pull'' ''git pull''
Zeile 188: Zeile 190:
  
 Lokales Ziel Lokales Ziel
- 
 <code> <code>
 +
 git checkout //master// git checkout //master//
  
Zeile 203: Zeile 205:
 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 ======
  
 ''git checkout – '' ''git checkout – ''
Zeile 221: Zeile 222:
  
 ====== Basis Konfiguration eines Repos ====== ====== Basis Konfiguration eines Repos ======
- 
  
 |<file> |<file>
Zeile 230: Zeile 230:
 git config -global core.editor [editor] git config -global core.editor [editor]
  
-</file>      |**GIT User Konfiguration setzen**   |+</file>       |**GIT User Konfiguration setzen**   |
 |''git config -l ''   |**Konfiguration zeigen**   | |''git config -l ''   |**Konfiguration zeigen**   |
 |''git status ''   |**zeigt,ob eine Datei editiert wurde**   | |''git status ''   |**zeigt,ob eine Datei editiert wurde**   |
Zeile 242: Zeile 242:
 |''git log ''   |**Letzte Commits zeigen**   | |''git log ''   |**Letzte Commits zeigen**   |
 |''git fetch <remote>''   |**Objektstruktur runterladen**   | |''git fetch <remote>''   |**Objektstruktur runterladen**   |
-  | +    |
- +
-====== Repo duplizieren ======+
  
 +===== Repo duplizieren =====
  
 Create a bare clone of the repository. Create a bare clone of the repository.
  
-$ git clone --bare https://github.com/exampleuser/old-repository.git+$ git clone bare [[https://github.com/exampleuser/old-repository.git|https://github.com/exampleuser/old-repository.git]]
  
 Mirror-push to the new repository. Mirror-push to the new repository.
  
-$ cd old-repository.git +$ cd old-repository.git $ git push mirror [[https://github.com/exampleuser/new-repository.git|https://github.com/exampleuser/new-repository.git]]
-$ git push --mirror https://github.com/exampleuser/new-repository.git+
  
 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 +
  
 ===== Alte commits entfernen ===== ===== Alte commits entfernen =====
- 
  
 Commits sichten Commits sichten
 +<code>
  
-<code> 
 git log --oneline git log --oneline
 +
 </code> </code>
  
-Neuen Branch erzeugen, aber ohne history (--orphan)+Neuen Branch erzeugen, aber ohne history (orphan)
  
 <code> <code>
 git checkout --orphan tem_branch git checkout --orphan tem_branch
 +
 </code> </code>
  
Zeile 281: Zeile 278:
 <code> <code>
 git add -A git add -A
 +
 </code> </code>
  
Zeile 287: Zeile 285:
 <code> <code>
 git commit -am "Initial commit message" git commit -am "Initial commit message"
 +
 </code> </code>
  
Zeile 293: Zeile 292:
 <code> <code>
 git branch -D main git branch -D main
 +
 </code> </code>
  
Zeile 305: Zeile 305:
 <code> <code>
 git push -f origin main git push -f origin main
 +
 </code> </code>
  
-====== Gitea ======+====== Git mit SSH ======
  
 +Mehrere ssh Key benutzen:
  
-Git with a cup of tea - A painless self-hosted Git service +Keys zum agent hinzufügen:
  
-https://gitea.io/en-us/+<code> 
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>ssh-add ~/.ssh/id_rsa3</font>
  
-https://dl.gitea.io/gitea/xxx/gitea-xxx-linux-arm64+</code>
  
-https://docs.gitea.io/en-us/upgrade-from-gitea/+.ssh/config
  
-Upgrade script: /etc/scripts/gitea_upgrade.sh+<code> 
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>Host gitea gitea.netzwissen.de</font>      ForwardAgent yes
  
 +#HostName gitea.netzwissen.de
 +# IdentityFile ~/.ssh/id_rsa_gitea
 +# User git
 +
 +Host 192.168.72.12
 +IdentityFile ~/.ssh/id_rsa
 +User thommie
 +
 +Host kakariki.netzwissen.de
 +HostName kakariki.netzwissen.de
 +IdentityFile ~/.ssh/id_rsa3
 +
 +</code>
 +
 +Im Repo selbst
 +
 +.git/config
 +
 +<code>
 + <font inherit/monospace;;inherit;;#000000background-color:#ffffff;>[core]</font>           repositoryformatversion = 0
 +       filemode = true
 +       bare = false
 +       logallrefupdates = true
 +**       sshCommand = ssh -i ~/.ssh/id_rsa**
 +[remote "origin"]
 +       url = ssh://git@gitea.netzwissen.de:2022/thommie/thommievault.git
 +       fetch = +refs/heads/*:refs/remotes/origin/*
 +[branch "main"]
 +       remote = origin
 +       merge = refs/heads/main
 +
 +</code>
 +
 +
 +====== Gitea ======
 +
 +Git with a cup of tea - A painless self-hosted Git service
 +
 +[[https://gitea.io/en-us/|https://gitea.io/en-us/]]
 +
 +[[https://dl.gitea.io/gitea/xxx/gitea-xxx-linux-arm64|https://dl.gitea.io/gitea/xxx/gitea-xxx-linux-arm64]]
 +
 +[[https://docs.gitea.io/en-us/upgrade-from-gitea/|https://docs.gitea.io/en-us/upgrade-from-gitea/]]
 +
 +Upgrade script: /etc/scripts/gitea_upgrade.sh
  
  
  • git_gitea.1696837526.txt.gz
  • Zuletzt geändert: 05/03/2024 - 10:52
  • (Externe Bearbeitung)