Skip to main content

Git without conflicts.

Project description

gitalong

PyPI version Documentation Status codecov

Gitalong is a tool for Git repositories that seek to prevent conflicts between files when working with a team. It uses hooks and a store to communicate local changes across all clones of a given remote. In turns this information can be leveraged by integrations to prevent modifying files that are already changed elsewhere.

Pre-requisites

[!TIP] Setting up Python and Git can be intimidating on Windows. You can make your life easier by installing Scoop and running scoop install python git in a Windows command prompt.

Installation

pip install gitalong

Usage

Shell

# Creating a dummy project repository and its clone in current working directory.
git init --bare project.git
git clone project.git project

# Creating a repository that Gitalong will use to store and share local changes.
# You would normally host this somewhere like GitHub so your entire team has access to it.
git init --bare store.git

# Setting up Gitalong in your project repository.
# This will clone the store repository in an ignored `.gitalong` folder.
# It will also start tracking a `.gitalong.json` configuration file.
gitalong -C project setup store.git --modify-permissions --tracked-extensions .jpg,.png --track-uncommitted --update-gitignore --update-hooks

# Creating some files.
touch project/untracked.txt
touch project/uncommitted.png
touch project/local.png
touch project/current.jpg
touch project/remote.jpg

# Spreading them across branches.
git -C project add current.jpg
git -C project commit -m "Add current.jpg"
git -C project add remote.jpg
git -C project commit -m "Add remote.jpg"
git -C project push
git -C project reset --hard HEAD^
git -C project add local.png
git -C project commit -m "Add local.png"

# Updating tracked commits with current local changes.
# Because we passed `--track-uncommitted`, uncommitted changes will be stored as sha-less commit.
# Because we passed `--modify-permssions` the file permissions will be updated.
# When passing `--update-hooks`, the update will happen automatically on the following hooks:
# applypatch, post-checkout, post-commit, post-rewrite.
gitalong -C project update

# Checking the status for the files we created.
# Each status will show <spread> <filename> <commit> <local-branches> <remote-branches> <host> <author>.
# Spread flags represent where the commit lives. It will be displayed in the following order:
# <mine-uncommitted><mine-active-branch><mine-other-branch><remote-matching-branch><remote-other-branch><other-other-branch><other-matching-branch><other-uncomitted>
# A `+` sign means is true, while a `-` sign means false or unknown.
gitalong -C project status untracked.txt uncommited.png local.png current.jpg remote.jpg

# Claiming the files to modify them.
# If the file cannot be claimed the "blocking" commit will be returned.
# Since we passed `--modify-permissions`, the claimed file will be made writeable.
# These claimed files will be released automatically on the next update if not modified.
gitalong -C project claim untracked.txt uncommited.png local.png current.jpg remote.jpg

Python

You can find a usage example in example.py.

Stores

As mentioned earlier, Gitalong needs an accessible place to store and share local changes with all clones of the managed repository. Multiple options are offered here.

Git repository

A Git repository can be used for this purpose. The advantage of this solution is that you won't need more infrastructure and security mechanisms than what is needed to access your project's repository. That said, pulling and pushing the data that way is pretty slow. This method is used in the usage examples above.

JSONBin.io

JSONBin.io is a simple JSON hosting service. You will get faster operations with this option but it may come at a cost depending on your usage. See how to set this up below.

Shell

gitalong -C project setup https://api.jsonbin.io/v3/b/<BIN_ID> --store-header X-Access-Key=<ACCESS_KEY> ...

Python

repository = Repository.setup(
    store_url="https://api.jsonbin.io/v3/b/<BIN_ID>",
    store_headers={"X-Access-Key": "<ACCESS_KEY>"},
    ...

Worth noting that <ACCESS_KEY> can be an environment variable such as $ACCESS_KEY.

Development

Setting up

Setup a Python virtual environment and run the following command.

python -m venv .venv
source .venv/bin/activate
pip install -e ".[ci]"

Testing

pytest - -cov - report = html - -cov = gitalong - -profile - svg

Documenting

sphinx-build ./docs/source ./docs/build

Building

python setup.py sdist bdist_wheel

Publishing

twine upload --username __token__ --verbose dist/*

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

gitalong-0.1.0.dev8.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

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

gitalong-0.1.0.dev8-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file gitalong-0.1.0.dev8.tar.gz.

File metadata

  • Download URL: gitalong-0.1.0.dev8.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for gitalong-0.1.0.dev8.tar.gz
Algorithm Hash digest
SHA256 c08d687c0597255a6ea2da5e0d14d3093f4b4268d8b1c5f767205d2e3cd55c84
MD5 3ada81b4e337977de0ac0f3628bbdd59
BLAKE2b-256 e205ea944e9a5980da98c8eee017d18a80c03836aefdbad7466ee28f3db3d1c0

See more details on using hashes here.

File details

Details for the file gitalong-0.1.0.dev8-py3-none-any.whl.

File metadata

  • Download URL: gitalong-0.1.0.dev8-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for gitalong-0.1.0.dev8-py3-none-any.whl
Algorithm Hash digest
SHA256 fdb71a6d97b423ea1f67993d06a894600cdad623ea7b864e59a3c264aafe1508
MD5 ce085f22e6ac58245912a2c9f487b444
BLAKE2b-256 462181b8c07b1ca95a384ee43e40e3301f8c6a9701677504cd5cd0afe6f050fe

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