Skip to content

Instantly share code, notes, and snippets.

@BoxResin
Last active January 16, 2023 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BoxResin/f05fcb3c98b6e145b54f21ce0169a2fb to your computer and use it in GitHub Desktop.
Save BoxResin/f05fcb3c98b6e145b54f21ce0169a2fb to your computer and use it in GitHub Desktop.
Git Commands
// Move the branch pointer to a different commit
git branch -f branch-name commit-name
// Cancel merging
git reset --hard ORIG_HEAD
git reset --merge ORIG_HEAD ;; If you wanna keep your changes
// Cancel editing a file
git checkout -- <file>
// Make a file unstaged
git reset HEAD <file>
// Rebase without changing the date
git rebase --ignore-date
// Stash only non-staged files
git stash --keep-index
// Create a patch file
git diff --no-prefix > output.patch
// Create a patch file from the current commit
git format-patch --no-prefix -1 @ --stdout > output.patch
// Apply the patch file
patch -p0 < output.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment