Last active
August 29, 2015 13:56
-
-
Save rgsingh/9301321 to your computer and use it in GitHub Desktop.
Squash last n commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Typically, a discussion between a repo owner and collaborator will result in a pull request being assigned back to | |
# the respective collaborator, a new commit created, and being assigned back to the repo owner for review. This interaction | |
# can result in many commits per pull request. | |
# If following the convention of a commit header message which prefixes with an issue number, squashing commits for the same | |
# issue is very easy. | |
# For example, if "git log" shows 3 commits with commit messages starting with "Issue #3" or "i3", it is easy to visually | |
# determine what "n" should be. | |
#git rebase -i HEAD-<n> | |
git rebase -i HEAD-3 | |
# The above will place you in the editor. Find the latest (in time) commit for the issue. Change "pick" to "squash". | |
# This will squash all (earlier) commits into the one (latest) commit. | |
# When you attempt to execute "git push", it will fail because the tip of the remote branch does not match the local one. | |
# Perform the following ONLY on your feature branch within your remote forked repository since you are the only one | |
# modifying it. | |
git push --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment