Inhaltsverzeichnis

Git Grundlagen

Übersicht

Befehl Beschreibung Beispiel
git init Neues lokales Repository erstellen
git clone <url> [<ZielVerzeichnis>]
git clone <path> [<ZielVerzeichnis>]
Kopie eines existierenden Git Repositorys anlegen
git submodule add <repository> <path> In einem Unterverzeichnis eines Git-Repositories eine Referenz auf ein anderes Git-Repositories eingebetten
git add <file> [<file> …] Dateien zur Versionsverwaltung hinzufügen
git commit -m '<Beschreibung>'
git commit –amend
Änderungen in die Arbeitskopie übermitteln
bzw. korrigieren
git status Zustand der Dateien prüfen
git log
gitk
Commit Historie anzeigen
git tag [-a] <tag> [-m '<beschreibung>'] Neuen Tag anlegen
git branch <feature1>
git checkout <feature1>
Mit branch wird der Branch erstellt.
Mit checkout wird zum Branch gewechselt.

Allgemeines

Benutzer und Passwort

$ git remote set-url origin https://name@github.com/repo.git
$ git remote set-url origin https://name:password@github.com/repo.git

Repository auschecken

$ git clone /pfad/zum/repository
$ git clone benutzername@host:/pfad/zum/repository
$ git -c http.sslVerify=false clone <repository-name>

Repository update vom Parent

git fetch
git rebase origin/master

clone subdirectory

$ git clone src_project/ dest_project/
$ cd dest_project
$ git filter-branch --prune-empty --subdirectory-filter clone_directory HEAD

Submodule

Add a submodule

$ cd <project>
$ git submodule add https://git.evenhausen.de/<submodule>.git <submodule_dir>
$ git submodule init

Commit and push submodule changes

$ cd <project/submodule_dir>
$ git add <stuff>
$ git commit -m "comment"
$ git push

Then tell your main project to track the updated version:

$ cd  <project>
$ git add <submodule_dir>
$ git commit -m "updated my submodule"
$ git push

update submodule

$ cd <submodule_dir>
$ git checkout master  # checkout desired branch
$ git pull             # update content

Disable SSL verification for a specific repository

$ git config --global http.sslVerify false

Nur Unterverzeichnis

$ git clone --no-checkout --depth 1 --sparse --filter=blob:none https://git.evenhausen.de/$ORG/$REPO.git
$ cd $REPO
$ git sparse-checkout init --cone
$ git sparse-checkout add relevant/dir/
$ git checkout master
Artikel Info
BeschreibungGit Grundlagen
Stand
Fertig
Version23.0415
Kategorien

Anleitung

,

Entwicklung

,

Grundlagen

,

Linux

,

Programmieren

,

Windows