-
-
Save aaccioly/4e724ec10d892fb0f90c93cf5cebd262 to your computer and use it in GitHub Desktop.
Revisions
-
aaccioly revised this gist
Jul 7, 2025 . 1 changed file with 27 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,14 @@ #!/usr/bin/env bash # SPDX-FileCopyrightText: 2019 Martin Wallgren # # SPDX-License-Identifier: MIT # # SPDX-FileContributor: Anthony Accioly <[email protected]> # # Changelog: # - 2025-06-16: Anthony Accioly - Added fzf preview, pbcopy support and default branch detection # # Original at: https://gist.github.com/MartinWallgren/5c00716d176350a842f46037a79f9230 function usage() { echo "Git command to help you select which commit to create a fixup commit for." echo "" @@ -34,19 +41,31 @@ while [ ! $# -eq 0 ]; do shift done upstream=$(git rev-parse --abbrev-ref "@{upstream}" &>/dev/null) # Determine the current branch and the default branch name dynamically. current_branch=$(git rev-parse --abbrev-ref HEAD) default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') if [ -z "$default_branch" ]; then default_branch="main" fi if [[ "${current_branch}" == "${default_branch}" ]]; then # If on the default branch, use all commits since root. fixup_range="$(git rev-list --max-parents=0 HEAD)..HEAD" elif [ -z "${upstream}" ]; then fixup_range="${GIT_DEFAULT_FIXUP_RANGE:-origin/${default_branch}..HEAD}" else fixup_range="${upstream}..HEAD" fi parent=$(git log --no-merges --oneline "${fixup_range}" | fzf --height "${FZF_TMUX_HEIGHT:-40%}" \ --preview "git show {1} --color=always" \ --bind "ctrl-y:execute-silent(echo {1} | cut -d' ' -f1 | pbcopy)+abort" | cut -d' ' -f1) if [ -z "${parent}" ]; then echo "No commit found to fix." else git commit --fixup="${parent}" "$@" fi -
MartinWallgren revised this gist
Jul 7, 2025 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ #!/bin/sh # SPDX-FileCopyrightText: 2019 Martin Wallgren # # SPDX-License-Identifier: MIT function usage() { echo "Git command to help you select which commit to create a fixup commit for." echo "" -
MartinWallgren revised this gist
Feb 26, 2019 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,20 @@ function usage() { echo "Git command to help you select which commit to create a fixup commit for." echo "" echo "The command will let you select a commit from a range and commit the current" echo "staging area using the selected commit as argument to the --fixup= option. Any" echo "extra options passed to this command will be forwarded to the git commit" echo "command." echo "" echo "The range will be the current upstream to HEAD. If no upstream is set for the" echo "current branch, the default range will be used. You can set the default range" echo "with GIT_DEFAULT_FIXUP_RANGE, if not set, origin/master..HEAD will be used as" echo "default range." echo "Example: GIT_DEFAULT_FIXUP_RANGE=origin/develop..HEAD git-fixup." echo "Note that a configured upstream branch will take precedence over the default range." echo "" echo "This command depends on fzf (https://github.com/junegunn/fzf)" echo "" echo "git-fixup" echo -e "\t-h --help" echo "" -
MartinWallgren revised this gist
Feb 26, 2019 . 1 changed file with 16 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ #!/bin/sh function usage() { echo "Git command to help you select which commit to create a fixup commit for." echo "" echo "The command will let you select a commit to fix in the range from to the" @@ -21,28 +20,28 @@ function usage() echo "" } while [ ! $# -eq 0 ]; do case "$1" in --help | -h) usage exit ;; esac shift done upstream=$(git rev-parse --abbrev-ref @{upstream} &>/dev/null) if [ -z "${upstream}" ]; then fixup_range="${GIT_DEFAULT_FIXUP_RANGE:-origin/master..HEAD}" else fixup_range="${upstream}..HEAD" fi parent=$(git log --no-merges --oneline ${fixup_range} | fzf --height ${FZF_TMUX_HEIGHT:-40%} | cut -d' ' -f1) if [ -z "${parent}" ]; then echo "No commit found to fix." else git commit --fixup=${parent} "$@" -
MartinWallgren revised this gist
Feb 26, 2019 . 1 changed file with 41 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,49 @@ #!/bin/sh function usage() { echo "Git command to help you select which commit to create a fixup commit for." echo "" echo "The command will let you select a commit to fix in the range from to the" echo "upstream to HEAD. If no upstream is set for the current branch," echo "origin/master..HEAD will be used as the range to select from. The default" echo "range can be overriden with the environment variable GIT_DEFAULT_FIXUP_RANGE." echo "" echo "Example: GIT_DEFAULT_FIXUP_RANGE=origin/develop..HEAD git-fixup. Note that a" echo "configured upstream branch will take precedence over GIT_DEFAULT_FIXUP_RANGE." echo "" echo "The command will let you select a commit from the range and commit the current" echo "staging area using the selected commit as argument to the --fixup= option. Any" echo "extra options passed to this command will be forwarded to the git commit" echo "command." echo "" echo "git-fixup" echo -e "\t-h --help" echo "" } while [ ! $# -eq 0 ] do case "$1" in --help | -h) usage exit ;; esac shift done upstream=$(git rev-parse --abbrev-ref @{upstream} &> /dev/null) if [ -z "${upstream}" ];then fixup_range="${GIT_DEFAULT_FIXUP_RANGE:-origin/master..HEAD}" else fixup_range="${upstream}..HEAD" fi parent=$(git log --no-merges --oneline ${fixup_range} | \ fzf --height ${FZF_TMUX_HEIGHT:-40%} | \ cut -d' ' -f1) if [ -z "${parent}" ];then echo "No commit found to fix." else git commit --fixup=${parent} "$@" fi -
MartinWallgren revised this gist
Feb 25, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,4 @@ parent=$(git log --oneline ${upstream}..HEAD | \ fzf --height ${FZF_TMUX_HEIGHT:-40%} | \ cut -d' ' -f1) git commit --fixup=${parent} "$@" -
MartinWallgren created this gist
Feb 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ #!/bin/sh upstream=$(git rev-parse --abbrev-ref @{upstream} &> /dev/null) if [ -z ${upstream} ];then upstream=origin/master fi parent=$(git log --oneline ${upstream}..HEAD | \ fzf --height ${FZF_TMUX_HEIGHT:-40%} | \ cut -d' ' -f1) git commit --fixup=${parent}