Created
July 29, 2013 15:37
-
-
Save rshk/6105231 to your computer and use it in GitHub Desktop.
Git snippets
This file contains hidden or 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
# Rewrite a bunch of commits to clean 'em up | |
# We have a bunch of commits we want to reorganize (anything | |
# after 2a23a731 needs to be reorganized..) | |
% git log --pretty=oneline | |
89bee8d13ae1b0047901d07b139d5980072cddbc fourth | |
984809f2bc6e9598439096dbf4333bbf1aee37d0 third | |
e714be8487bdbb64eb1efc2caa071695825d633f second | |
2a23a731833bb701fae3767452865d4120fadcf4 first | |
% git checkout -b work | |
% git rebase -i 2a23a731 | |
# now, "pick" the first commit, "squash" the others | |
# ...and commit | |
% git log --pretty=oneline | |
a52ffe9c7493bbebfb278f00a7f4d2f6be76ab67 My new commit | |
2a23a731833bb701fae3767452865d4120fadcf4 first | |
% git reset HEAD~1 | |
% git status | |
# you're now on 2a23a731, with all the changes from a52ffe9c | |
# as unstaged in the working copy. | |
# Now, you can commit only the parts you want, as usual. | |
# It is very handy to use ``git add -p`` to only stage parts | |
# of a file, instead of whole files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment