Skip to main content

The git_sync Module

Project description

CircleCI Travis Codecov Pypi Downloads

The git_sync module.

Github

https://github.com/Erotemic/git_sync

Pypi

https://pypi-hypernode.com/project/git_sync

This is a very simple git script to help with local development and remote execution. It turns the process of commiting, logging into the remote machine, and then pulling on the remote machine into a single command.

Assuming that you have the same file structure on both your local and remote machine, git-sync allows you to edit files locally, and when you want those changes reflected on the remote machine, you execute

`bash git-sync other-machine `

Details

Executing git-sync performs the following actions:

  1. Executes a git commit to the local repo (the default commit message is “wip”, but this can be changed using the -m flag).

  2. Executes a git push origin which pushes the local copy of the repo to the git server. (Note, git-sync defaults to the origin git remote, but you can specify a different one using a second positional argument: e.g. git-sync other-machine remote2).

  3. Creates an SSH connection to “other-machine”, cd’s into the same directory you are in on the local machine (which is why mirroring the directory structure across development machines is important), and then executes a git pull origin, which will update the remote machine to the newly pushed state.

Caveats

Note that this script is very simple, it will fail if these conditions aren’t met.

  • The location of the repo (relative to the home directory) must be the same on the local and remote machine. Note, it is fairly easy to ensure this is the case using symlinks.

  • The repo on the local machine and remote machine must be on the same branch.

  • The repo on the remote machine must be in a clean state.

On SSH Configs

Also, to make life easier, it is best that you have a $HOME/.ssh/config file setup with the remote machines you to access and appropriate identify files so you don’t need to enter your password each time you git-sync.

An example ssh config entry is:

Host {myremote} {myremote.com}
    HostName {myremote.com}
    Port 22
    User {username}
    identityfile ~/.ssh/{my_id_ed25519}

Replacing any entry in {curly braces} with an appropriate value.

If you don’t have an ssh identify file, create one using:

mkdir -p $HOME/.ssh
cd $HOME/.ssh

FPATH="$HOME/.ssh/my_id_ed25519"
ssh-keygen -t ed25519 -b 256 -C "${EMAIL}" -f $FPATH -N ""

chmod 700 ~/.ssh
chmod 400 ~/.ssh/id_*
chmod 644 ~/.ssh/id_*.pub

And ensure the public key is registered with the remote machine:

REMOTE={myremote.com}
REMOTE_USER={myusername}
ssh-copy-id $REMOTE_USER@$REMOTE

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_sync-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distributions

git_sync-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

git_sync-0.1.0-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file git_sync-0.1.0.tar.gz.

File metadata

  • Download URL: git_sync-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for git_sync-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b804a762cfc55f04245fa6b6c5ce0cfe53516fc2ac85717d5f8eb250147e8bf2
MD5 0e2e92f3706d40deaaf5a51db2c6909b
BLAKE2b-256 fda9db8f649a200490eceb669af2e9751709027d8016913b4ed91a3dd228ed0a

See more details on using hashes here.

File details

Details for the file git_sync-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: git_sync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for git_sync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45228d496c2785098d21ba18f4b7714ba12f13708779700663e3b07149cf6999
MD5 cda0870ece212cc2afb6bad49b257335
BLAKE2b-256 6956504b4e17b97783991e24d69afca16938a3e87cf4ed3bb46d357d7c17dcd7

See more details on using hashes here.

File details

Details for the file git_sync-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: git_sync-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for git_sync-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dd9f207cba9e1165cbc6a3e2871c8418aa502db1ced0b5524838fc7a315cf0c4
MD5 3ee73bcbf11c20df184bddf46977cfd3
BLAKE2b-256 c723be9d621d0275efc2f90a320955db91bccad5097b2835f982ee13c24d983b

See more details on using hashes here.

Supported by

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