Skip to content

Instantly share code, notes, and snippets.

@rlancejohnson
Last active August 2, 2022 22:29
Show Gist options
  • Select an option

  • Save rlancejohnson/5558a89d991914d951ef92f2c18f67e4 to your computer and use it in GitHub Desktop.

Select an option

Save rlancejohnson/5558a89d991914d951ef92f2c18f67e4 to your computer and use it in GitHub Desktop.
Git Commands Used Most Often

Git Commands Used Most Often

Branching

  • git switch -c {newBranch} {fromBranch}
  • git push -u origin {localBranch}
  • git branch -u {remoteBranch} {localBranch}

Committing

  • git commit -m "{message}"

  • git commit --ammend {commitSHA}

  • git reset {branchName} ~{numberOfCommitsBack}

  • git reset {commitName} ~{numberOfCommitsBack}

  • git reset HEAD ~{numberOfCommitsBack}

  • git revert {branchName} ~{numberOfCommitsBack}

  • git revert {commitName} ~{numberOfCommitsBack}

  • git revert HEAD ~{numberOfCommitsBack}

  • git restore -s {branch or commit name} {fileName}

Logging

  • git log -p --full-diff -- {filePath}
  • git log --stat --graph

Pulling

  • git fetch
  • git pull

Pushing

  • git push

Branch Management

  • git push origin -d {remoteBranch}

  • git branch -d {localBranch}

  • git cherry-pick {commitName} {commitName} {branchName}...

  • git rebase {branchName} ~{numberOfCommitsBack}

  • git rebase {commitName} ~{numberOfCommitsBack}

  • git rebase HEAD ~{numberOfCommitsBack}

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