tj / tj/git-extras

proposal: git-flick, move a commit to another branch

Open
#33 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

While working on a feature branch, I often come across and fix various minor issues (e.g. code readability). Ideally such commits should live on a separate branch to avoid obscuring feature changes.

Based on IRC conversations (#git on FreeNode), here's what I came up with (tentatively called git-flick, for lack of inspiration):

#!/usr/bin/env bash

set -e
set -x

treeish=${1:?}
target_branch=${2:?}

git checkout "$target_branch"
git cherry-pick "$treeish"
# return to original branch
git checkout @{-1}
# remove commit from original branch
# NB: rebase shortens treeish to seven characters; rebasing from commit's parent
GIT_EDITOR="grep -v ${treeish:0:7}" git rebase -p -i "${treeish}^"

(This is not extensively tested yet.)

If this is deemed of general interest, I could submit a pull request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides a proposed Bash entry point for git-flick; start by reviewing that script and how this repository organizes Git utilities. Done means a repository-integrated command can move a selected commit to another branch without leaving it on the original branch, with behavior validated beyond the issue's currently untested example.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.