Skip to main content

Enhanced git workflow utilities with smart conflict resolution and branch management

Project description

GIT Shortcuts

Some git shortcuts for better workflow management.

Installation

You must have git installed and available in your PATH to use this tool.

Install virtual environment

You may want a standalone virtual environment for this tool, or you can install it globally. To create a virtual environment off your home directory, run:

python -m venv ~/.venv
source ~/.venv/bin/activate

Install git-shortcuts

pip install git-shortcuts

Add to PATH

If you installed globally, the gscut command should already be available. If you installed in a virtual environment, you need to add the virtual environment's bin directory to your PATH. For example, if you created a virtual environment at ~/.venv, you can add the following line to your shell profile (e.g., ~/.bashrc or ~/.zshrc):


Verify Installation

gscut --help

Usage

Safe checkout

Quickly checkout a branch without worrying about losing work. This is especially useful when you have a lot of uncommitted changes, and you want to switch to another branch to work on something else, but you don't want to lose your changes.

gscut checkout <branch>

Merge without conflicts

Quickly merge a branch without worrying about conflicts. Conflicted files will be added to the repo with the foreign branch name appended to the filename. You can resolve conflicts later by comparing the files and selecting the changes you want to keep.

gscut merge <branch>

Alias branch names

Corporate repositories often have long branch names that are difficult to remember and type. You can create aliases for these branch names to make it easier to work with them.

Create a new branch with an alias:

gscut checkout -b feature/user-authentication --as ua

Or create from a specific base branch:

gscut checkout -b hotfix/security-patch --as hsp --from main

Create an alias for an existing branch:

gscut alias <branch name> --as <short name>

Or create an alias for the current branch:

gscut alias --as <short name>

Then checkout using the alias:

gscut checkout ua

Features

  • Smart Stashing: Automatically stashes changes when switching branches, including untracked files
  • Staged/Unstaged Preservation: Restores files to their exact staged/unstaged state after switching
  • Conflict Resolution: Creates .branch-name copies of conflicted files for easy comparison
  • Branch Aliases: Short aliases for long branch names
  • Flexible Syntax: Arguments can be in any order (e.g., --as alias --from base -b name)

Examples

# Create branch without alias
gscut checkout -b feature/new-feature

# Create branch with alias
gscut checkout -b feature/user-authentication --as ua

# Create from specific base branch
gscut checkout -b hotfix/critical --from production

# All options together (any order)
gscut checkout -b feature/api-v2 --as api2 --from develop
gscut checkout --as api2 --from develop -b feature/api-v2

# Switch to existing branch
gscut checkout main
gscut checkout ua  # using alias

# Merge with automatic conflict resolution
gscut merge feature/new-api

# Create alias for existing branch
gscut alias feature/very-long-branch-name --as vlbn

# Create alias for current branch
gscut alias --as cb

Development Installation

Install in editable mode so changes to the code are immediately reflected:

# Clone the repository
git clone https://github.com/klahnakoski/git-shortcuts.git
cd git-shortcuts

# Install in development mode
pip install -r tests/requirements.txt
pip install -r packaging/requirements.txt
pip-compile packaging/requirements.txt -o packaging/requirements.txt


pip install -e .

This creates a gscut command available system-wide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_shortcuts-1.706.26062.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_shortcuts-1.706.26062-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file git_shortcuts-1.706.26062.tar.gz.

File metadata

  • Download URL: git_shortcuts-1.706.26062.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for git_shortcuts-1.706.26062.tar.gz
Algorithm Hash digest
SHA256 633569af946cc6ffc25681cc44ac2754dbf528bd2c45b0555b1c642fe9825770
MD5 cf42a287871f3a843294709a88d4aa67
BLAKE2b-256 13488e14097a39841763a48594390c703e52a81ce21515efac472ea51c94e059

See more details on using hashes here.

File details

Details for the file git_shortcuts-1.706.26062-py3-none-any.whl.

File metadata

File hashes

Hashes for git_shortcuts-1.706.26062-py3-none-any.whl
Algorithm Hash digest
SHA256 49cbdf24cab9491ec63370982095822db2e4f7d9471970575e16a07c9e3d4a27
MD5 27f4f6bc4257390c009104457428bb7b
BLAKE2b-256 10e80414edb19e9317a41badeca51edd0f8eac02146a7ca1ccbb4b72ead5e640

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page