Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Tool to checkout a specific commit to a unique location

Project description


Tool to checkout a specific commit to a unique location


pip install .


  --repository /path/to/git/repo
  --checkout-dir /path/to/version/location
  -c commit_hash

--use-prefix prefixes the directories in checkout_dir with the repository name

To get the final path use an additional --get-path, i.e.

  --repository /path/to/git/repo
  --checkout-dir /path/to/version/location
  -c commit_hash

this will only print the path but not checkout the code. Its intendented to be used in a variable.

example usage in scripts

source env/bin/activate
checkout_code --repository ~/src/sockeye --checkout-dir ~/work/sockeye/ -c $COMMIT --use-prefix
path=$(checkout_code --repository ~/src/sockeye --checkout-dir ~/work/sockeye/ -c $COMMIT --use-prefix --get-path)

development version a.k.a HEAD

if you specify the commit as HEAD the tool will not checkout anything but the --get-path option will return your repository. That way you can use HEAD to point to your latest, possible uncommited, version

environment files

To make it easier to use you can also use .env files instead or in addition to CLI-options. You can specify the file by using --env /path/to/.env/file or it will automatically search for files. In the environment file just use


to specify your settings.

Note command line arguments will always override environment settings

version history

0.1 2018-03-08

  • initial version

0.2 2018-03-08

  • added file lock
  • added requirements

0.3 2018-03-20

  • added loading of env files

0.4 2018-07-13

  • return exit code 1 if checkout_dir does not exists

0.5 2019-02-08

  • add default timeout for filelock (closes #2)
  • added option to change timeout value

Project details

Release history Release notifications

This version


Download files

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

Files for checkout-code, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size checkout_code-0.5-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size checkout_code-0.5.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page