Doku: Git Everyday Use
GIT Basics
Lokale Standard-Instanzen
- Arbeitskopie = die echten Dateien, dynamisch
git add
addiert den aktuellen Datenstand in den Index („Stage“)- Ein
git commit -m „Commit-Nachricht“
übernimmt den Status nach HEAD. HEAD zeigt immer auf letzten Commit
Leeres Repository erzeugen und die darin vorhandenen Dateien in den lokalen git Index aufnehmen
git init git add .
Initialer Commit, um den aktuellen Stand im HEAD aufzunehmen
git commit -m „Commit-Nachricht“
Verknüpfen des lokalen git mit Github: Definition von "origin" und "upstream"
Nach dem Anlegen eines eigenen Repos auf github kann man das lokale Repo mit dem Repo auf github verknüpfen: „origin“ .
- origin = persönliches git Repo auf Github. Die kann auch ein privater Fork eines öffentlichen Repos auf github sein, also (github offentliches Repo » github privates Repo).
- upstream = das öffentliches Github Repo (z.B. https://github.com/owncloud/core). Änderungen im origin werden per pull request (PR) in den upstream übernommen.
Alle lokalen Änderungen landen zuerst im „origin“ und derst danach per Pull Request im öffentlichen Repo.
Lokal: hinzufügen des entfernten „origin“
git remote add **origin** git@github.com:thommierother/oc-theme-nw2.git git push -u origin master
Analog geht das Verbinden des öffentlichen Repos als „upstream“:
git remote add **upstream** ''git@github.com:https://github.com/owncloud/docs.git''
Kontrolle Remote Ziele „origin“ und „upstream“
git remote -v origin git@github.com:thommierother/docs.git (fetch) origin git@github.com:thommierother/docs.git (push) upstream git@github.com:owncloud/docs.git (fetch) upstream git@github.com:owncloud/docs.git (push)
Synchronisation der lokalen Objekt Struktur mit der entfernten
holen
git fetch origin
Änderungen vom Fork
git fetch upstream
Änderungen von upstream
pushen
git push origin
Änderungen nach Fork senden
git push upstream
Änderungen nach upstream senden
Github: entferntes Repo klonen
Lokale Kopie des aktuellen Arbeitsstandes auf github anlegen
git clone /pfad/zum/
repository
git commit -m „Commit-Nachricht
Änderungen hochladen
Update des Fork auf Github
Das geht über das lokale Repo:
Updates von Upstream holen
''$ git fetch upstream''
Zum master wechseln
''git checkout master''
Master mit upstream mergen
''git merge upstream/master''
Danach push auf den fork setzen.
Branches
Wo bin ich (aktueller Branch)
git show branch
Alle Branches im Repo zeigen
git branch -a main * master remotes/origin/HEAD -> origin/main remotes/origin/main remotes/origin/master
Zum anderen Branch wechseln
git checkout master
Freier Wechsel zu Branch
git checkout [branchname]
Lokal erzeugten Branch im remote Repo verfügbar machen
git push origin master
synchronisiert in den Master Branch vom Remote Repo (origin).“origin„ weist auf den (privaten) Fork eines Github-zentralen Repos.
Neuen Branch erstellen und zu diesem wechseln
git checkout -b feature_x
Branch löschen
git branch -d feature_x
update & merge
git pull
Holt Änderungen von Remote (fetch) und führt sie mit dem lokalen Stand zusammen (merge). Bei Konflikten: Dateien manuell korrigieren und danach die geänderte Datei mit git add [dateiname]
einbauen. Die Unterschiede sieht man mit
git diff <quell_branch> <ziel_branch>
Upstream nach fork mergen
Lokales Ziel
git checkout //master//
Welche branch von Upstream soll wohin geholt werden?
git pull git@github.com:owncloud/docs.git BRANCH_NAME
Danach commit, review und push auf den fork bei Github
Wenn etwas ganz schiefgeht
git checkout –
setzt die lokalen Änderungen auf den letzten HEAD Stand. Änderungen, die du bereits zum Index hinzugefügt hast, bleiben bestehen.
Hard Reset = Zurück auf den letzten Stand vom entfernten Repository:
git fetch origin
git reset –hard origin/master
Pull requests
Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github
Basis Konfiguration eines Repos
git config -global user.name [name] git config -global user.email [email] git config -global core.editor [editor] | GIT User Konfiguration setzen |
git config -l | Konfiguration zeigen |
git status | zeigt,ob eine Datei editiert wurde |
git-diff and git-status | Show the working tree status |
git commit | Änderungen einspielen |
git checkout -b branch2 | Wechsel zwischen Branches: Neuen Branch erstellen und dort hin wechseln |
git-reset[1] | Reset current HEAD to the specified state |
git-merge | Join two or more development histories together |
git-rebase | Reapply commits on top of another base tip |
git tag | Tags zeigen (z.B. einzelne Releases) |
git log | Letzte Commits zeigen |
git fetch <remote> | Objektstruktur runterladen |
Atom
https://flight-manual.atom.io/
Globale Tastenkürzel
Kürzel | was machts | Anmerkung |
---|---|---|
Ctrl-Shift-P | Kommando-Palette | |
Ctrl-T oder Ctrl-P | Suche nach Dateiname im Projekt | |
Ctrl-B | Suche nach Text in offenen Dateien im Projekt | |
Ctrl-F | Suche nach Text in allen offenen Dateien | |
Ctrl-Shift-F | Suche nach Text in alle Dateien im Projekt |
Markdown Syntax on GitHub
Atom Fenster ausserhalb des sichtbaren Bereiches
https://github.com/atom/atom/issues/6939
Workaround:
atom –clear-window-state
oder
ALT+TAB–>select atom ALT+space–> select maximize.
oder für Windows
- Select the Atom window (using Alt-Tab or mouse)
- Open the context menu with Alt-Space.
- Select move using “m”
- Press any of the arrow keys.
- The Atom window will now be possible to drag back to the main monitor using the mouse.
ASCIIDoc
Admonition
<nowrap> NOTE: An admonition paragraph draws the reader's attention to auxiliary information. Its purpose is determined by the label at the beginning of the paragraph.
Here are the other built-in admonition types:
TIP: Pro tip…
IMPORTANT: Don't forget…
WARNING: Watch out for…
CAUTION: Ensure that… </nowrap>
Formatierung
<nowrap> old *constrained* & unconstrained
italic _constrained_ & unconstrained
bold italic *_constrained_* & un constrained
monospace `constrained` & ``un``constrained
monospace bold `*constrained*` & ``un``constrained
monospace italic `_constrained_` & ``un``constrained
monospace bold italic `*_constrained_*` & ``un``constrained </nowrap>
Document header
<nowrap> = My Document's Title Doc Writer doc.writer@asciidoctor.org v1.0, 2018-04-11 :toc: :imagesdir: assets/images :homepage: https://asciidoctor.org
My document provides… </nowrap>
Überschriften
= Document Title (Level 0) == Level 1 Section Title === Level 2 Section Title ==== Level 3 Section Title ===== Level 4 Section Title ====== Level 5 Section Title == Another Level 1 Section Title
Listen
Unordered, basicview result
* Edgar Allen Poe * Sheri S. Tepper * Bill Bryson
Unordered, basic (alt)view result
- Edgar Allen Poe - Sheri S. Tepper - Bill Bryson
xx