All Projects → keis → Git Fixup

keis / Git Fixup

Licence: isc
Fighting the copy-paste element of your rebase workflow.

Programming Languages

shell
77523 projects

Labels

Projects that are alternatives of or similar to Git Fixup

Shelby
Shelby is a fast ⚡️ , lightweight ☁️ , minimal✨, shell prompt written in Go.
Stars: ✭ 148 (-14.45%)
Mutual labels:  zsh
Zsh Syntax Highlighting
Fish shell like syntax highlighting for Zsh.
Stars: ✭ 13,245 (+7556.07%)
Mutual labels:  zsh
Zsh 100 Commits Club
Promote writing Zsh software not simple scripts
Stars: ✭ 165 (-4.62%)
Mutual labels:  zsh
Zsh Prompt Garrett
A prompt with the information you need the moment you need it.
Stars: ✭ 150 (-13.29%)
Mutual labels:  zsh
Promptless
🚀 A super fast and extremely minimal shell prompt.
Stars: ✭ 155 (-10.4%)
Mutual labels:  zsh
Installomator
Installation script to deploy standard software on Macs
Stars: ✭ 159 (-8.09%)
Mutual labels:  zsh
Nicy
❄️ a nice and icy zsh and bash prompt in Nim
Stars: ✭ 148 (-14.45%)
Mutual labels:  zsh
Zsh In Docker
Install Zsh, Oh-My-Zsh and plugins inside a Docker container with one line!
Stars: ✭ 169 (-2.31%)
Mutual labels:  zsh
Gh
Easily manage your local git repos
Stars: ✭ 156 (-9.83%)
Mutual labels:  zsh
Z.lua
⚡ A new cd command that helps you navigate faster by learning your habits.
Stars: ✭ 2,164 (+1150.87%)
Mutual labels:  zsh
Dotfiles
📍 My dotfiles for macOS using Fish/Zsh, Neovim, and Tmux
Stars: ✭ 151 (-12.72%)
Mutual labels:  zsh
Tmoe Linux
🍭Without any basic knowledge of linux shell,you can easily install and configure a GNU/Linux graphical desktop environment on 📱Android termux and 💻WSL .🍰You can also run VSCode on your android phone.🍹Graphical qemu manager,🐋support running docker on Android.配置WSL和安卓手机的linux容器,桌面环境,主题美化,远程桌面,音频服务,镜像源,uefi开机启动项,webdav(nginx),fcitx输入法以及qemu-system虚拟机...
Stars: ✭ 149 (-13.87%)
Mutual labels:  zsh
Zimfw
Zim: Modular, customizable, and blazing fast Zsh framework
Stars: ✭ 2,219 (+1182.66%)
Mutual labels:  zsh
Wsl Config
CS 4400 - Step by step guide for using WSL and Vim as a development environment
Stars: ✭ 148 (-14.45%)
Mutual labels:  zsh
Dotfiles Win
🙈 oh-my-zsh on bash on windows configuration files
Stars: ✭ 167 (-3.47%)
Mutual labels:  zsh
Dotfiles
~ 🍭 ~
Stars: ✭ 147 (-15.03%)
Mutual labels:  zsh
Enhancd
🚀 A next-generation cd command with your interactive filter
Stars: ✭ 2,049 (+1084.39%)
Mutual labels:  zsh
Powerline
Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.
Stars: ✭ 12,989 (+7408.09%)
Mutual labels:  zsh
Dotfiles
vim, zsh, git, homebrew, nvm, neovim - my whole world
Stars: ✭ 2,217 (+1181.5%)
Mutual labels:  zsh
Zsh Proxy
🔩 An oh-my-zsh plugin to configure proxy
Stars: ✭ 162 (-6.36%)
Mutual labels:  zsh

git-fixup

Fighting the copy-paste element of your rebase workflow.

git fixup <ref> is simply an alias for git commit --fixup <ref>. That's just a convenience feature that can be also be used to trigger tab completion.

The magic is in plain git fixup without any arguments. It finds which lines/files you have changed, uses git blame/log to find the most recent commits that touched those lines/files, and displays a list for you to pick from. This is a convenient alternative to manually searching through the commit log and copy-pasting the commit hash.

git fixup

Install

On OS X you can install this script with homebrew

brew install git-fixup

On Arch linux you can install from AUR using yaourt or a similar tool

yaourt git-fixup

For most other systems (as long as they include install and make) you can install by cloning this repo and running make

git clone https://github.com/keis/git-fixup.git
cd git-fixup
make install
make install-zsh

Or if you don't want to deal with any of that you can simply download the scripts in anyway you like and make sure to put the program and completion script into your $PATH and $fpath respectively.

Usage

git-fixup [-s|--squash] [-f|--fixup] [-c|--commit] [<ref>]

For this tool to make any sense you should enable the rebase.autosquash setting in the git config.

# Select the changes that should be part of the fixup.
$ git add -p

# Output a list of commits that the staged changes are likely a fixup of.
$ git fixup

# Create a fixup!-<commit> of the given ref. If you have installed the zsh script
# you can cycle through the list of fixup candidates with tab completion.
$ git fixup <ref>

# Commit rebased into the selected commit as a fixup.
$ git rebase -i ...

Options

-s, --squash

Instruct git-fixup to create a squash! commit instead of a fixup! commit.

Squashing gives you the opportunity to edit the commit message before the commits are squashed together.

Default action can be configured by setting fixup.action

-f, --fixup

Instruct git-fixup to create fixup! commit (This is the default).

Default action can be configured by setting fixup.action

-c, --commit

Instead of listing the suggested commits show a menu to pick a commit to create a fixup/squash commit of.

A default menu is provided that is intentionally very simple and with no advanced features. Instead of using it you can tell git fixup to use an external tool for the menu by defining a command line via either the fixup.menu setting in the git config or the GITFIXUPMENU environment variable (the latter overrides the former).

# Use fzf as a menu program
$ GITFIXUPMENU=fzf git fixup -c

This option can be enabled by default by setting fixup.commit in the git config.

--no-commit

Don't show the commit menu even if previously instructed to do so.

Configuration

git-fixup uses configuration from the ENVIRONMENT or from git config

fixup.action

Or GITFIXUPACTION

Decides if the default actions will be fixup or squash.

fixup.commit

Or GITFIXUPCOMMIT

Decides if the commit menu should be displayed instead of the commit list by default.

# Enable --commit for all my projects
$ git config --global fixup.commit true

fixup.menu

Or GITFIXUPMENU

Sets the command that will be used to display the commit menu. If not set a simple [default menu](default menu] will be used.

See External menu for more details and a more advanced example.

Tab completion

Tab completion for zsh is implement and the suggestions for the tab completion is the suggested fixup bases as generated by running the tool without any arguments.

To be able to tab complete the command itself add a line like this to your zsh configuration::

zstyle ':completion:*:*:git:*' user-commands fixup:'Create a fixup commit'

External menu

In order to use an external tool for display the commit menu, you need to either define the fixup.menu setting in the git config or set the GITFIXUPMENU environment variable with the command for the menu. The menu command must receive as input the lines as the options for the user and return the selected line to the standard output.

The following example is a fragment of a git config that makes git fixup --commit display a nice menu with fzf:

[fixup]
    menu = fzf --height '60%' \
                --bind 'tab:toggle-preview' \
                --preview 'git show --color {+1}' \
                --preview-window=up:80% \
                --prompt 'Select commit: '

The default menu

If you have not configured an external menu, the default menu is used. See the example below:

$ git fixup -c
1) 500be603c66040dd8a9ca18832d6221c00e96184 [F] Add README.md <[email protected]>
2) ddab3b03da529af5303531a3d4127e3663063e08 [F] Add index.js <[email protected]>
Which commit should I fixup? <your-selection>

Here <your-selection> should be the number of the desired commit in the list. You can use q to abort the operation and h to see a help message for the menu.

If the commit title alone is not enough for you to decide, you can use show <number> to call git show on the <number>-th commit of the menu.

Changelog

See CHANGELOG.md

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].