Mein git Cheatsheet

Offensichtlich gehört es zum guten Ton, ein Git-Cheatsheet zu veröffentlichen. Deshalb mal eins von mir, Voraussetzung git > Version 2.4

:3

  • create new repo
git init my_repo
  • repo clonen
git clone https://gitrepo.test/git/my_repo
  • updaten
git pull
  • tags ansehen
git tag
git tag -l
git tag -n
  • remote tags ansehen
git ls-remote --tags origin
  • zu speziellem Tag springen
git checkout v2.0
  • tags createn
git tag v1.0
  • tags pushen
git push --tags
  • code einchecken
git add .
  • code committen
git commit -m "my_message"
  • code zum server
git push
git push origin/master
  • vi zum mergen verwenden
git config merge.tool vimdiff
  • MD5-Summe anzeigen des letzten commits
git rev-parse --short HEAD
  • Files anzeigen
git ls-files
  • Files aus repo entfernen
git rm filename
  • change History anzeigen
git log
  • Git Graph anzeigen
git log --oneline --graph --all
  • Branch switchen ohne deteached head state
git switch -c my_branch --track origin/my_branch
git switch my_branch
git checkout my_branch
  • Branch switchen MIT deteached head state
git checkout origin/my_branch
git switch --detach origin/my_branch
  • Status ansehen
git status

HEAD detached at origin/my_branch
nothing to commit, working tree clean
  • kein grafisches Ask-Password-Fenster
git config --global core.askpass ""
  • git Config ansehen
git config --global -l
  • Username global
git config --global user.name
  • username pro Repo
git config user.name
  • Email global
git config --global user.email
  • credential helper examples
git config credential.helper 'store'                  # stores the credentials indefinitely.
git config credential.helper 'cache'                  # stores for ?
git config credential.helper 'cache timeout=3600'     # stores for 60 minutes
  • cred helper with bash
git config --global credential.helper "/bin/bash ~/git_creds.sh"
echo '#!/bin/bash' > ~/git_creds.sh
echo "sleep 1" >> ~/git_creds.sh
echo "echo username=SERVICE_USER" >> ~/git_creds.sh
echo "echo password=SERVICE_PASS" >> ~/git_creds.sh
chmod 700 ~/git_creds.sh
  • cred with ssh
eval $(ssh-agent -s)

echo "password" | ssh-add ~/.ssh/id_rsa

git pull origin master
  • graphical view
gitk
Artikel erstellt am: 10 March 2023 , aktualisiert am 11 March 2023