Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active March 3, 2020 18:13
Show Gist options
  • Save joshschmelzle/9c0be8d49f5b0f6ba797444da039d5f2 to your computer and use it in GitHub Desktop.
Save joshschmelzle/9c0be8d49f5b0f6ba797444da039d5f2 to your computer and use it in GitHub Desktop.
git-cheatsheet-and-notes.md
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
git config --global core.editor vim
git config --list
git config user.name
git config user.email
git help config

Using GitHub? Setup SSH keys tutorial

Where are your git config values being read from?

git config --list --show-origin

It tells you where all the values are coming from. Thanks @jessitron!

Make your local branch track the remote one

# syntax
git checkout -b <branch> --track <remote>/<branch>
# ex
git checkout -b release/core47 origin/release/core47

Credential Helper

git config credential.helper store                    #stores the credentials indefinitely.
git config credential.helper 'cache --timeout=3600'   #stores for 60 minutes

squash

note: HEAD~8 means squash the last 8 commits

git status
git reset --hard HEAD~8
git merge --squash HEAD@{1}
git commit
git push
git push --force

needs merge

git fetch origin
git reset --hard origin/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment