Git: Unterschied zwischen den Versionen

Aus Nicki Wiki
Zur Navigation springen Zur Suche springen
 
(22 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
= Häufige Befehle =
= Häufige Befehle =
== Config ==
git config --global user.name "Your Name"
git config --global user.email "your_email@example.de"
git config --global core.editor "vim"
Benutzername und Passwort für eine bestimmte Zeit speichern:
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=600'
== Clone ==
== Clone ==
  git clone <Repo-Pfad>
  git clone <Repo-Pfad>
Zeile 7: Zeile 16:


== Branch ==
== Branch ==
  git checkout <Branch-Name> #branch auschecken
  git checkout <Branch-Name>                 # branch auschecken
  git checkout -b iss53       #Neuen branch anlegen und auschecken
  git checkout -b iss53                     # Neuen branch anlegen und auschecken
git push --set-upstream origin iss53      # push new branch
git branch -d iss53                        # delete branch local
git push origin --delete iss53            # delete branch remote
git checkout -- <Datei>                    # Änderung verwerfen
git branch -m <newname>                    # branch Namen ändern
git push --set-upstream origin <newname>  # neuen branch Namen remote bekannt machen
git branch -f Dev ad4f43af43e              # branch Dev dem commit ad4f43af43e zuordnen
   
   
  git checkout -- <Datei>    #Änderung verwerfen
  git push -d origin dev                    # branch dev remote löschen


== Stage/Commit ==
== Stage/Commit ==
  git add .                  #Stagen
  git add .                  # Stagen
  git reset HEAD <Datei>     #Staging verwerfen
  git reset .                # Stage verwerfen
 
git commit -m "commit Text" # Commit
git reset --soft HEAD^      # Commit Rückgängig machen
git reset --hard HEAD^     # Commit verwerfen


  git commit -m "commit Text"
  git rev-parse HEAD               # Zeigt HASH lang
git reset --soft HEAD^      #Commit Rückgängig machen
  git log --pretty=format:'%h' -n 1 # Zeigt HASH kurz
  git reset --hard HEAD^      #Commit verwerfen


== Submodule ==
== Submodule ==
  git submodule add -b master <Repo-Pfad> <lokaler-Pfad>
Ist im Repo ein submodule und in diesem ebenfalls ein submodule welches mann updaten möchte muss das aus dem ersten submodule mit <code>git submodule update --remote</code> erfolgen.
  git submodule init
  git submodule add -b master <Repo-Pfad> <lokaler-Pfad> # add submodule
  git submodule update
  git submodule init                                      # init
  git submodule update --init --recursive # init + update + untermodule
  git submodule update --remote                          # update submodule
  git submodule update --init --recursive                 # init + update + sub-submodule


  git clone --recurse-submodules https://path
  git clone --recurse-submodules https://path
git submodule update --remote                          # pull all changes for the submodules
== Tag ==
git tag -a v0.1 -m "Kommentar" # Tag
git push origin v0.1          # push Tag remote

Aktuelle Version vom 6. Oktober 2023, 11:00 Uhr

Häufige Befehle

Config

git config --global user.name "Your Name"
git config --global user.email "your_email@example.de"
git config --global core.editor "vim"

Benutzername und Passwort für eine bestimmte Zeit speichern:

git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=600'

Clone

git clone <Repo-Pfad>
git clone --branch <Branch-Name> <Repo-Pfad>
git clone --recurse-submodules <Repo-Pfad>
git clone --branch <Branch-Name> --recurse-submodules <Repo-Pfad>

Branch

git checkout <Branch-Name>                 # branch auschecken
git checkout -b iss53                      # Neuen branch anlegen und auschecken
git push --set-upstream origin iss53       # push new branch
git branch -d iss53                        # delete branch local
git push origin --delete iss53             # delete branch remote

git checkout -- <Datei>                    # Änderung verwerfen

git branch -m <newname>                    # branch Namen ändern
git push --set-upstream origin <newname>   # neuen branch Namen remote bekannt machen

git branch -f Dev ad4f43af43e              # branch Dev dem commit ad4f43af43e zuordnen

git push -d origin dev                     # branch dev remote löschen

Stage/Commit

git add .                   # Stagen
git reset .                 # Stage verwerfen
git commit -m "commit Text" # Commit
git reset --soft HEAD^      # Commit Rückgängig machen
git reset --hard HEAD^      # Commit verwerfen
git rev-parse HEAD                # Zeigt HASH lang
git log --pretty=format:'%h' -n 1 # Zeigt HASH kurz

Submodule

Ist im Repo ein submodule und in diesem ebenfalls ein submodule welches mann updaten möchte muss das aus dem ersten submodule mit git submodule update --remote erfolgen.

git submodule add -b master <Repo-Pfad> <lokaler-Pfad>  # add submodule
git submodule init                                      # init
git submodule update --remote                           # update submodule
git submodule update --init --recursive                 # init + update + sub-submodule
git clone --recurse-submodules https://path
git submodule update --remote                           # pull all changes for the submodules

Tag

git tag -a v0.1 -m "Kommentar" # Tag
git push origin v0.1           # push Tag remote