Code Monkey home page Code Monkey logo

git-extract's Introduction

git-extract

Use fzf to extract files into clean commits from work-in-progress branches

usage

git extract <source_branch> <target_branch> [<main_branch>]

example

$ git extract origin/wip-feature-dirty feature-clean origin/main

installation

Just drop the git-extract script into your $PATH and make sure it's executable.

demo

record-2023-06-27-07-56-50-root.teet.gawk.mp4

motivation

I often work on long-living dirty feature branches, saving garbage "wip" checkpoints, before I fully understand what am I even doing.

When the feature is finished and tested, I end up with the garbage log that's mostly meaningless, but not quite. I find it hard to separate sensible commit messages from those that served only as a snapshot of some intermittent state.

Usually the main units I can reason about are files/directories/namespaces etc. So before submitting a proper PR, I need to, not only rebase against the main branch, but also tidy up the log.

This script aims to help with that, provided I know which paths should eventually end up in the clean, public branch annotated with descriptive commits others could then review.

The script will open a new fzf multi picker window with all the files changed between <source_branch> and <main_branch>. After selecting one or more files, it will switch to <target_branch>, creating it, if necessary, and then restore selected file(s) into it.

The commit message will be pre-populated with a comment containing all the commit messages associated with selected file(s), as seen in <source_branch>.

In case multiple authors were involved, the Co-authored-by header(s) will be automatically added.

git-extract's People

Contributors

aerosol avatar

Stargazers

Jose R. avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.