Skip to content

Instantly share code, notes, and snippets.

@eddiecorrigall
Last active July 25, 2017 18:12
Show Gist options
  • Save eddiecorrigall/675a95f130ca3d681a2268204a7b29c6 to your computer and use it in GitHub Desktop.
Save eddiecorrigall/675a95f130ca3d681a2268204a7b29c6 to your computer and use it in GitHub Desktop.
Git commands

GIT Notes

Shortcuts

Nearly every page on GitHub has a keyboard shortcut to perform actions faster. https://help.github.com/articles/using-keyboard-shortcuts/

Squash branch changes

git checkout feature-branch
git rebase -i release-branch
git push --force

Common commit between branches

git merge-base branch1 branch2

Searching for commits

Grep

git grep pattern

Top 2

git log -2

By Window of Time

git log --after="2016-02-29 00:00" --before="2016-02-29 23:59"

Commits by author

git log --author=eddiecorrigall

Tagging Releases

git checkout release-branch
git pull

... make any necessary changes

git tag release-branch-rc2
git push --tags

Restore Files

Assuming the feature branch is currently checked-out, replace the existing feature branch file with the release branch file:

git checkout origin/release-branch path/file.py

Rebasing

  • Base commit; the previous commit of your first commit on the feature branch
git checkout release-branch
git pull
git checkout feature-branch
git rebase --onto origin/release-branch base_commit_of_feature_branch
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment