git

Local auth

The easiest way to avoid creating a token.

brew install gh

gh auth login

Branches

descriptioncommand
checkout branchgit checkout <branch name>
create branchgit branch <branch name>
remove local branchgit branch -D <branch name>
remove remote branchgit push origin --delete <branch name>
list branchgit branch
sync local branch to remote origin/maingit fetch origin && git merge origin/main

Commits

descriptioncommand
take the most recent commit and add new staged change to itgit commit --amend
remove all untracked files including ignoredgit clean --fdx
uncommit change but keep filesgit reset --soft HEAD^
remove all untracked filesgit restore .
move head to a commit and discard changes aftergit reset --hard <COMMIT_ID>
force syncing remote to localgit push --force
rebase to maingit checkout main && git pull && git checkout <FEATURE> && git rebase main
merge to mainuse sqash and merge

Files

descriptioncommand
move changes to stashgit stash
move changes out of stashgit stash pop
revert a file to its state in maingit checkout origin/main [filename]

Misc

descriptioncommand
pretty loggit log --all --decorate --oneline --graph
emojihttps://gitmoji.dev/