Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
Last active July 5, 2020 15:05
Show Gist options
  • Save h4k1m0u/8013665bac747e103e0fe4c5788e23f7 to your computer and use it in GitHub Desktop.
Save h4k1m0u/8013665bac747e103e0fe4c5788e23f7 to your computer and use it in GitHub Desktop.
Cheatsheet for Git commands

Resolve conflicts using local modifications

git fetch origin master
git rebase -X theirs

theirs means ours in the case of a rebase (inverse of git merge).

Double-dash

Means the end of command options, after which only positional parameters are accepted.

Move files from one repo to another

Text and binary files will be created and commits are also moved with their author dates kept.

git log -p --pretty=email --binary --reverse > <patch-file>
git am --directory=<directory> <patch-file>

Change order of commits

git rebase -i HEAD~5
Use vim to move commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment