Right after executing this command, your favorite editor will open up and present the list of commits you just selected (by providing a base commit).Īs a reminder: although you might be tempted to do so, we do not change the commit message here. Since we have to (at least) go back to the parent of our “bad apple” commit, we’re starting our session at HEAD~3 (three commits behind the HEAD commit, which is the one that’s titled “Change headlines …”): $ git rebase -i HEAD~3 Our first step is to determine the base commit for starting this interactive rebase session. You don’t need Tower to follow along in this tutorial.įor our example, let’s say that we’d like to edit the message of the commit currently titled “Optimize markup structure in index…” Note: For a better overview and clearer visualization, I’m using the Tower Git desktop client in some of my screenshots. Below is an image of a bad commit message that needs to be corrected. ![]() Let’s take a look at a concrete scenario. For any commit older than that, we have to use interactive rebase! You might be aware that git commit -amend also allows you to change a commit’s message - but only if it’s the very latest commit. One of the very popular use cases of interactive rebase is that you can edit an old commit message after the fact. With this theoretical overview out of the way, let’s dive into some practical cases together! I’ll demonstrate this point in practice shortly! Here, we are only going to tell Git what we want to do - but not make the actual change. Don’t make your actual changes in this editor window! Although you might be itching to simply go ahead and change the commit message in this editor window (after all, that’s what we actually want to do …), you have to show some patience. ![]() Don’t worry: your Git repository is fit as a fiddle! □ Remember that we’re in the process of performing an interactive rebase operation, and this requires Git to reapply the commits from oldest to newest at the end of the operation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |