Skip to main content

The git_well module

Project description

Pypi PypiDownloads GithubActions Codecov ReadTheDocs

Read the docs

https://python-git-well.readthedocs.io

Github

https://github.com/Erotemic/git_well

Pypi

https://pypi.org/project/git_well

Git Well is a collection of git command line tools and is also a Python module.

Installing this module installs the git-well command, which is a modal CLI into several new git commands. These git commands are also exposed as standalone “git” executables.

In other words after you:

pip install git-well

To get CLI argument completion install autocomplete, and you can enable global auto-completion

pip install argcomplete
mkdir -p ~/.bash_completion.d
activate-global-python-argcomplete --dest ~/.bash_completion.d
source ~/.bash_completion.d/python-argcomplete

And add this to your .bashrc

if [ -f "$HOME/.bash_completion.d/python-argcomplete" ]; then
    # shellcheck disable=SC1091
    source "$HOME"/.bash_completion.d/python-argcomplete
fi

NOTE: if you know of a way to make this easier please let me know!

Then you can run

# Show all the commands exposed by this repo.
git well --help

git well sync --help

# OR

git sync

Top Level CLI:

usage: git-well [-h] {squash_streaks,branch_upgrade,sync,branch_cleanup,track_upstream,rebase_add_continue,remote_protocol,discover_remote} ...

options:
  -h, --help            show this help message and exit

commands:
  {squash_streaks,branch_upgrade,sync,branch_cleanup,track_upstream,rebase_add_continue,remote_protocol,discover_remote}
                        specify a command to run
    squash_streaks      Squashes consecutive commits that meet a specified criteiron.
    branch_upgrade      Upgrade to the latest "dev" branch. I.e. search for the branch
    sync                Sync a git repo with a remote server via ssh
    branch_cleanup      Cleanup branches that have been merged into main.
    track_upstream      Set the branch upstream with sensible defaults if possible.
    rebase_add_continue
                        A single step to make rebasing easier.
    remote_protocol     Helper to change a remote from https to ssh / git for a specific user /
    discover_remote     Attempt to discover a ssh remote based on an ssh host.

The tools in this module are derived from:

Use Cases

Have you ever run into this error when you run git pull?

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> the_current_branch

I find this a huge pain because it can’t even be bothered to fill in <branch> so you have to munge the command to type:

git branch --set-upstream-to=origin/the_current_branch the_current_branch

I get why they did this, the branch on the remote might have a different name. But… it usually doesn’t. That’s why I implemented git-well track-upstream.

Running this instead will detect if you are in the simple case and just do it for you. Otherwise it will enumerate your options and ask you to pick one.

I’ve found this command to prevent so much disruption that instaling git-well install git track-upstream as its own command.

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_well-0.2.4.tar.gz (45.1 kB view details)

Uploaded Source

Built Distribution

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

git_well-0.2.4-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file git_well-0.2.4.tar.gz.

File metadata

  • Download URL: git_well-0.2.4.tar.gz
  • Upload date:
  • Size: 45.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for git_well-0.2.4.tar.gz
Algorithm Hash digest
SHA256 119c55b11be4908ac6928e87216e4361ee65032e9e0b822210fb393ef15feee0
MD5 1a9e8879714306394232ca8bec8f0079
BLAKE2b-256 2672084e0acc0968a0ef641fdc7b2ea7a7e51c4aecb90c2efe043756b54f4d1e

See more details on using hashes here.

File details

Details for the file git_well-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: git_well-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 48.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for git_well-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 53d29dbec7f29b63b9054bd0a3a476b62b7ddf0f213bdad94a16ee5ff6cab9b3
MD5 e5a64adf0b890a6c570461b5d939fe93
BLAKE2b-256 ff2d1df4328ea8cc13727fefee1abdfa90772c4c2fb27b7ecdd88a45bd18c79e

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