Skip to content

Instantly share code, notes, and snippets.

@priscillamc
Last active May 20, 2025 14:21
Show Gist options
  • 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

Check if a branch has been merged without commit

git merge --no-commit BRANCH_NAME

Comments are disabled for this gist.