Skip to content

Instantly share code, notes, and snippets.

@gyfoster
Last active April 16, 2019 20:26
Show Gist options
  • Select an option

  • Save gyfoster/c9f2c5e332b57884b6472b30de3e0678 to your computer and use it in GitHub Desktop.

Select an option

Save gyfoster/c9f2c5e332b57884b6472b30de3e0678 to your computer and use it in GitHub Desktop.
A list of my most commonly used git commands
BRANCHES
---------
Create a new branch from a current branch:
$ git checkout -b <new-branch>
Create a new branch from an existing branch:
$ git checkout -b <new-branch> <existing-branch>
Delete local branch:
$ git branch -D <branch-name>
Delete remote branch:
$ git push origin --delete <branch-name>
FILE CHANGES
-----------
List new and modified files:
$ git status
Show file differences not yet staged:
$ git diff
Show staged file differences:
$ git diff --staged
Stage files:
$ git add .
Unstage file, preserving contents:
$ git reset <file>
Commit:
$ git commit -m "<commit-message>"
List commits:
$ git log --oneline
List local commits not pushed yet:
$ git cherry -v
Go back to the most recent commit:
$ git reset --hard head
Go back to a previous commit:
$ git reset <commit>
Stash changes:
$ git stash
Apply stashed changes:
$ git stash apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment