aidanholm / git-prev-next

Simple way to edit in a git commit history

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Have you ever begun an interactive rebase to edit a commit, and then find that you also want to edit the parent commit? Or just wanted to edit a few commits back without going through the interactive rebase rigamarole?

git-prev-next is a pair of custom git commands to make it easier to navigate and rebase in a git commit history. It is built on top of interactive rebase.

Example

> # Oops, I need to make a change three commits up
> git prev 3
...hack hack hack...
> git commit --amend
> # oh I need to fix the next commit too
> git next
...hack hack hack...
> git commit --amend
> # all done
> git rebase --continue

git prev

This takes the current HEAD commit and prepends it to the rebase todo list (as 'pick'). It then resets to the parent commit.

If there is not a current interactive rebase, git prev will begin one.

You can pass a number like git prev 3 to go up 3 commits.

git next

This takes the next entry in the todo list, switches it to 'edit', and then invokes git rebase --continue. Note this terminates the interactive rebase if it reaches the top.

You can also pass a number to git next.

Installation

Install through copying or symlinking into your $PATH. For example:

ln -s $PWD/git-prev ~/.bin
ln -s $PWD/git-next ~/.bin

Safety

git prev and git next will refuse to enter or exit merge commits. They also will error if your worktree is not clean.

About

Simple way to edit in a git commit history

License:Other


Languages

Language:Shell 100.0%