July 20, 2019

Git QuickRef

git

Just a list of handy git commands

clone a repogit clone url
clone a repo into a folder with different name than the reopgit clone url folder
switch branchgit checkout branchname
pull content for current branch with rebase local changesgit pull --rebase
remove local branches that have no longer a remotegit remote prune origin
revert last local commitgit reset --soft HEAD~1
remove a directory from gitgit rm -r --cached node_modules
git commit -m 'rm ignored directory node_modules'
git push origin master
show refloggit reflog
(exit with "q")
show configgit config -l
set origin (for ssh)git remote set-url origin git@gitlab.com:_gitlabuser_/repository
show remotesgit remote -v
  • init directory
  • set remote
  • create branch
git init
git remote add origin git@github.com:me50/mwohlf.git
git checkout -b ai50/projects/2020/x/crossword
git add .
git commit -m "initial commit crossword"
git push --set-upstream origin ai50/projects/2020/x/crossword

set config values like email and username

git config user.name "FIRST_NAME LAST_NAME"
git config user.email "MY_NAME@example.com"

line endings

Windows uses both a carriage-return character and a linefeed character for newlines in its files (CRLF \r\n). Mac and Linux systems use only the linefeed character (LF, \n).


https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf

https://git-scm.com/book/en/v2