Skip to content

Instantly share code, notes, and snippets.

@dserodio
Last active December 17, 2018 12:50
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 dserodio/833fc02a223305e1b20d64a57d2da385 to your computer and use it in GitHub Desktop.
Save dserodio/833fc02a223305e1b20d64a57d2da385 to your computer and use it in GitHub Desktop.
Some git tips

Don't blame people for changing whitespaces or moving code

git blame will show the author of the last commit that modified the particular line. If whitespaces were removed or that piece of code was moved around, blame will show that commit and you might blame the wrong person.

git blame -w -M

-w will ignore whitespaces and -M will detect moved or copied lines.

Source: https://coderwall.com/p/x8xbnq/git-don-t-blame-people-for-changing-whitespaces-or-moving-code

Merge branches with conflicting indentation

git merge -s recursive -Xignore-space-change

Source: http://stackoverflow.com/a/5262473/31493

Rewrite history enforcing code style

Use git filter-branch.

Source: http://stackoverflow.com/a/4112426/31493

Rebasing an outdated pull request

git checkout feature_branch
git remote update
git rebase origin/master
git push -f feature_branch

Find the ancestor from which a branch was created

git merge-base --fork-point <ancestor> [<branch>]

<branch> is optional if you're comparing with the current branch

Source: https://stackoverflow.com/a/29813554/31493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment