📑
Chris Johnson's KB
  • Chris Johnson's KB
  • Meta
    • Pages to Add
  • Cheat Sheets
    • Apache
    • Docker
    • Gatsby
    • Git
    • GraphQL
    • iOS
    • MySQL
    • Nginx
    • NextJS
    • NodeJS
    • Rails
    • React
    • Security Tools
    • Shell (Linux)
    • SwiftUI
    • Ubuntu Server
    • Vim
  • Computing
    • Mac
    • iOS
    • ChromeOS
    • Windows
    • Browser Plugins
    • RSI Prevention
    • Voice Control
    • AWS Cloud 9
    • Visual Studio Code
    • Linux
  • Workflows
    • Podcasting
    • Setting up a new Mac
    • Site Deploys
  • Hardware
    • Dell U2720Q Monitor
    • Moonlander Keyboard
    • Apple Silicon Macs
  • Productivity
    • Structure
    • Nuggets of Wisdom
  • Coffee
    • Coffee Notes & Equipment
    • Coffee Beans
    • AeroPress Recipes
    • V60 Recipes
    • Moka Pot Recipes
    • French Press Recipes
  • Gaming
    • Rocket League
  • Food
    • Cocktails
    • Favorite Recipes
    • Whisky Reviews
    • Infinity Bottle
    • Favorite Wines
  • Inspiration
    • Quotes
  • Philosophy
    • Life
    • Programming
  • Fitness
    • Diets
    • Exercise Notes
    • Personal Training Notes
Powered by GitBook
On this page
  • Commands
  • Aliases to add to .gitconfig file
  • GitHub CLI

Was this helpful?

  1. Cheat Sheets

Git

Commands

Remove a file from the repo without deleting it:git rm --cached MYFILE.TXT

Remove a directory from the repo without deleting it:git rm --cached -r MYDIRECTORY

Search through git branches: git branch --all | grep -i MYSEARCH

Reset remote "busted_branch" with the contents of a "better_branch"

Make sure everything is pushed up to your remote repository, then checkout your busted_branch:

git checkout busted_branch

Overwrite busted_branch with better_branch:

git reset --hard better_branch

Force the push to your remote:

git push -f origin busted_branch

Resolve conflicted file with "their" changes:

git checkout --theirs path/to/file

Resolve conflicted file with "our" changes:

git checkout --ours path/to/file

Aliases to add to .gitconfig file

To prevent weird indenting, set paste mode in vim: :set paste

[user]
  name = Your Name
  email = your@email.com
[core]
  quotepath = false
  autocrlf = input
  editor = 'vim'
[push]
  default = simple
  autoSetupRemote = true
[alias]
  co = checkout
  ec = config --global -e
  up = !git pull --rebase --prune $@ && git submodule update --init --recursive
  cob = checkout -b
  cm = !git add -A && git commit -m
  save = !git add -A && git commit -m 'SAVEPOINT'
  wip = !git add -u && git commit -m "WIP"
  undo = reset HEAD~1 --mixed
  amend = commit -a --amend
  wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
  bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs -r g:it branch -d; }; f"
  bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
  st = status
  logp = log --pretty=oneline --max-count=20
  subinit = !git submodule init && git submodule update
  mmain = !git fetch origin main && git merge origin/main
  mmaster = !git fetch origin master && git merge origin/master

When done pasting: :set nopaste

GitHub CLI

Install on Mac: brew install gh

Auth: gh auth login

Check current PR check status: gh pr checks

Create PR: gh pr create

Check PR statuses: gh pr status

Merge PR: gh pr merge

Checkout PR: gh pr checkout PR_NUMBER_HERE

Edit PR: gh pr edit

PreviousGatsbyNextGraphQL

Last updated 21 days ago

Was this helpful?

Sources:

https://dev.to/thomaslombart/how-to-save-time-with-github-cli-b9n