Skip to content

Instantly share code, notes, and snippets.

@priscillamc
Last active Feb 6, 2021
Embed
What would you like to do?
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