# Git cheat sheet #### Checka ut specifik commit git checkout {{sha}} #### Checka ut senaste commit git checkout master #### Byt remote
git remote rm origin
git remote add origin {{URL to repo}}
git push -u origin master
git remote -v
Alternativt
git remote rm origin
git remote add origin {{URL to repo}}
git pull origin master
git branch --set-upstream-to=origin/master
git pull
#### Slå ihop flera repon #### Merge project-a into project-b:
cd path/to/project-b
git remote add project-a /path/to/project-a
git fetch project-a --tags
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge
git remote remove project-a
#### Pull repository, ignorera och skriv över lokala filer
git fetch --all
git reset --hard
git pull
#### Återställ lokal arbetskatalog till utcheckad version git reset --hard VARNING - Ta bort icke trackade filer. Lägg till parametern "n" för "dry run" för att se vilka filer som kommer att raderas. git clean -f -d VARNING - Som ovan men raderar ävan ignorerade filer. git clean -f -x -d VARNING - Som ovan men raderar även filer i underkataloger (utan :/ rensas bara aktuell katalog) git clean -fxd :/ ## Konfigurera CR/LF
git config --global core.autocrlf false
Detta är oftast default.
git config --global core.eol lf
När filer checkas ut används alltid LF som EOL.
git config core.eol crlf
Kan användas för att använda CRLF som EOL endast i aktuellt repository. Om identiska (bortsett från CR/LF) filer ersätts i aktuell arbetskatalog hanterar inte Git detta automatiskt. För att normalisera dessa använd:
git add --renormalize .
## Autentisering #### Aktivera Windows Credentials manager
git config --global credential.helper manager
git config --list
#### Kontrollera användarinformation lagrad i Windows Credentials manager rundll32.exe keymgr.dll,KRShowKeyMgr