git-quickfix

Crates.iogit-quickfix
lib.rsgit-quickfix
version0.1.0
sourcesrc
created_at2020-09-23 07:01:14.601693
updated_at2022-06-21 02:46:16.53565
descriptionA small utility to apply patches outside of the current branch.
homepagehttps://github.com/siedentop/git-quickfix
repositoryhttps://github.com/siedentop/git-quickfix
max_upload_size
id291992
size78,892
Christoph Siedentop (siedentop)

documentation

https://github.com/siedentop/git-quickfix

README

Git QuickFix

Quickfix allows you to commit changes in your git repository to a new branch without leaving the current branch.

Motivation

I have often written a patch for some minor blemish that caught my attention. I found it annoying to have to stage my main changes, switch to a new branch created off the main branch, commit and push the patch and then switch back to the original branch.

Benefits

  • Minimize context switching.
  • Much quicker on large repositories, where branch switching takes significant time.
  • Everything happens in memory, so tools and IDEs watching the file system will not get confused.

How it works

  1. Commit the changes.

  2. git quickfix --push <new_branch>

    • This will create a new branch named <new_branch> based-off origin/main (or whatever the remote default branch is).
    • The last commit on your current branch will be cherry-picked onto this new branch.
    • Leave out --push if you do not want to push the new branch to origin.
  3. git quickfix --help provides more options.

    • With --onto <branch> you can modify the branch from which <new_branch> is based-off.
    • With --remove the last commit will be removed from the original branch.
    • Add --autostash if you have local changes that you want to temporarily stash.

The cherry-pick is done in memory. This means your working directory will not be modified.

The quickfix commit will be kept (changed in v0.0.5) unless --remove is provided.

Installation

You can use Cargo to install quickfix.

Cargo is available for all major platforms. How to install Cargo is described here: https://doc.rust-lang.org/cargo/getting-started/installation.html

cargo install git-quickfix

Known Issues

  • Default branches from origin are picked up through a hard-coded list. Patches welcome. If the default branch on the remote is not called main, master, devel, or develop, you have to supply it manually. Similarly, if the remote is not called 'origin' you will also have to supply the branch name manually using the --onto option. Please create an issue if this bothers you.

  • Won't fix: --push use the shell to push the changes. Benefits: All proxy, auth and other configs are picked up. But if does not feel right.

FAQ

  • Can it handle multiple commits? -- No. I am trying to keep the tool simple. However, I originally started with this. If you see a need, please create a feature request.
  • Are commit hooks considered? -- Not really. While the original commit will have pre- and post-commit hooks run, the cherry-pick itself does not run the pre-commit hook. As far as I understand, this may be the git behavior, or maybe not? None of it matters, as libgit2 does not support hooks. If you have a use for a particular git-hook, please create a new ticket.
  • How does this work? -- libgit2 provides a raw cherry-pick method. This works in-memory, meaning that the working directory (i.e. the checked out files) can be left untouched. This method returns a raw Index object, which I use to create a new commit.

Related Work

Commit count: 52

cargo fmt