Skip to content

Instantly share code, notes, and snippets.

@priscillamc
Last active February 6, 2021 20:17
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 priscillamc/832e53ffa9d581d8b6ea712f3108982b to your computer and use it in GitHub Desktop.
Save priscillamc/832e53ffa9d581d8b6ea712f3108982b to your computer and use it in GitHub Desktop.
Helpful git commands

Git Commands

Merging branches

Merge specific files from another branch into current branch

git checkout branchname filename filename

git checkout branchname dir1/ dir2/

Merge conflicts

Quit merge before a commit

git merge --abort

If you have multiple files and you want to accept local/our version, run:

grep -lr '<<<<<<<' . | xargs git checkout --ours

If you have multiple files and you want to accept remote/other-branch version, run:

grep -lr '<<<<<<<' . | xargs git checkout --theirs

Tagging Commits

View tags

git tag

Add a tag

git tag v1.0.0

Move a tag to a new commit

git tag --force v1.0.0 <ID-of-commit>
git push --force --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment