There are a couple options here, but we’ll go ahead and mark commits we’d like to meld with it’s successor by changing pick to squash. # Rebase 4095f73.ec48d74 onto 4095f73 (3 commands) # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit Pick ec48d74 Added comments & updated README Pick 3f8e810 Updated screenreader attributes Git will open up your default terminal text editor (most likely vim) and present you with a list of commits: pick 7f9d4bf Accessibility fix for frontpage bug This lets Git know I want to operate on the last three commits back from HEAD. With my bug fix branch checked out, I’ll start by running the interactive rebase command with HEAD~3. I’d rather combine them together into one clean commit. It would be nice if I didn’t have to preserve these extraneous commits as separate entities since they are all related to a bug fix. Again, we’ll say my starting point is my bug fix branch with 3 commits. Now that you know what squash is, let’s take a look the actual commands. Squashing allows you to rewrite history and combine together commits. ![]() Or you have a bunch of local commits related to a bug fix, but you’d really rather just have all of those related commits under one roof. ![]() Usually, preserving commits like this is a good idea, but let’s say you made a typo somewhere and had to create another commit to fix the spelling error. I’ll need to get my commits back onto mainline, and I can use merge or rebase to do that however, with either solution, all my local branch commits would be preserved.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |