Skip to content

Instantly share code, notes, and snippets.

@esutton
Last active December 14, 2022 16:42
Show Gist options
  • Save esutton/034252aaab16ec3d50227bad779c1d18 to your computer and use it in GitHub Desktop.
Save esutton/034252aaab16ec3d50227bad779c1d18 to your computer and use it in GitHub Desktop.
Git Cheatsheet

Git Cheatsheet

Create New branch and Push to Remote

# Use <yourInitials>/branch-name to organize your branches
git checkout -b my/new-branch
git push origin my/new-branch

Switch to Branch

# List all branches
git branch -a
git switch my/branch1

Diff Branches

git diff my/branch1..my/branch2

# List file names only
git diff my/branch1..my/branch2 --name-only

git diff my/branch2 master -- path/to/file/to/compare

Copy file from branch into current branch

git checkout my/branch1
git checkout my/branch2 path/to/file1

Undo

# Undo all modified files in current dir
git checkout -- .

Recreate a Deleted Branch

git checkout -b <your-branch> <sha>

Azure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment