But what I have to keep telling myself is, "You want to reset to the reflog before 'rebase' starts to appear."Īs an example, here's a reflog after I've done some rebasing on a branch called gitPoetryRebase. I've learned over time that the reflog entry I need might indicate a checkout just took place, or perhaps a can be different, which can be confusing. And because the reflog list is in reverse chronological order, the correct reflog will be just below the rebase entries and have a higher index number in between the curly brackets ( ). The answer is to use the entry before the ones with the rebase flag. But when I look at the results of git reflog, I see a ton of entries that contain the word rebase. And I know I can use git reset -hard to return my working directory and index to the way things were at a particular time. I know I can use git reflog to see where HEAD was at various stages in time. Now I realize I messed something up, and I want to go back to the way things were before I touched git rebase -i. This particular poem addresses a problem that is hopefully unique to me: I've just done an interactive rebase, squashing commits, editing others, etc. With most of the commands here, we're not destroying any work we're either committing it or stashing it. Once we are done adding our selected changes to the index and we commit them, we can run git stash save -p to go through a similar process to add selected bits of changes to save in a single stash. A prompt from Git will show us each hunk one by one, asking if we'd like to stage the hunk, disregard it, split it into smaller hunks, etc. The git add -p command will look at all the unstaged changes in our working directory and break them into "hunks" for us. Some changes we want to add to our index to commit, and some changes we want to stash for later. All in all, where applicable, -p allows us to take manipulative actions incrementally instead of wholesale.įor example, let's say we've made a lot of changes to our working directory. The -p option, or -patch, is incredibly handy when we want to perform a Git action with only some of the changes we have made. An Ode to `git reset -soft`, `git reset`, and `git reset -hard`.Further Wonders Using the `-p` Option (aka, `-patch`). I suggest that when you see something like -p, you read it as "dash p," and when you see something like -patch, you read it simply as "patch." But that can be tricky when incorporating command-line flags or options. I tried to keep a consistent cadence with each rhyme. These links are appropriately entitled "What?" Each rhyme (or series of related rhymes) is followed by a link to the command and a bit of discussion. To hide the ball a bit, the actual command inspiring the rhyme is "hidden" away at the bottom of this page. The heading above each rhyme gives a sense of the situation or problem where the rhyme might come in handy. The rhymes assume you are familiar with Git already they go beyond basic commands. I hope there's something in these rhymes that you can take away to assist you as well, whether it gets you out of a jam in Git or just helps you get the children to sleep faster. My attempt to describe them in rhyming stanzas is an attempt to make them easier to recall. The verses below focus on the Git tricks that slip my mind from time to time. Are you having a hard time remembering that one Git command? Or maybe you need new nursery rhymes to read the kids before bed? If you're like me, it's easier to commit details to memory when they're in a song or rhyme, so this blog can help you with both!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |