Git Product home page Git Product logo

git-auto-sync's Introduction

Git Auto Sync

GitAutoSync is a simple command line program to automatically commit changes to your git repo, and always keep that repo up to date. This way you can use any editor with your text files, and never need to worry about comitting and remembering to push and pull changes.

Installation

  • OSX - brew install GitJournal/tap/git-auto-sync
  • Linux -
    • Ubuntu/Debian -

      sudo echo "deb [trusted=yes] https://apt.fury.io/vhanda/ /" | sudo tee /etc/apt/sources.list.d/git-auto-sync.list
      sudo apt-get update
      sudo apt-get install -y git-auto-sync
    • Fedora/RPM -

      sudo echo -e "[git-auto-sync]\nname=Git-Auto-Sync\nbaseurl=https://yum.fury.io/vhanda/\nenabled=1\ngpgcheck=0" | sudo tee /etc/yum.repos.d/git-auto-sync.repo
      sudo yum update
      sudo yum install -y git-auto-sync
    • Arch Linux - Please write an AUR package and open a PR for this. You're an Arch User. You got this.

    • Other - Download the latest release

  • Windows - Download the latest release

How to use?

GitAutoSync comes with a manual and daemon mode. It's recommended to start with the manual mode to ensure authentication is working correctly. It internally just calls the git executable so, if that works, git-auto-sync should just work.

You can test it out by running git-auto-sync sync to commit, pull, rebase and push any changes. If there are no changes, it will just attempt to pull, rebase and push.

Once you're satisfied that git-auto-sync is working for you. You can run git-auto-sync daemon add <repoPath> to start a background daemon which will continously monitor that repo for any changes in the file system and accordingly sync the changes.

This daemon will be automatically started as a system process.

You can check if it is running git-auto-sync daemon status

Background Daemon

The background daemon will be started / stopped automatically if there are any repos to watch in git-auto-sync daemon ls. This process will monitor the filesystem, poll every 10 minutes, and additionally try to sync on resuming from a suspend. The latter two are done to pick up changes from the remote.

Merge Conflicts

GitAutoSync current only supports rebases, and doesn't yet attempt to do a merge. In the case of a rebase conflict, it will abort and stop syncing that repo. It will send a system notification to inform you of the conflict.

Ignored Files

It currently ignores all hidden files, files ignored by git, and additional temporary swap files created by vim, emacs and similar editors.

Similar Projects

git-auto-sync's People

Contributors

vhanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-auto-sync's Issues

Background Process for Auto Syncing Git Repos was skipped

Hi Vishesh,
Thanks for putting your efforts into this. I was making use of a bash script and cron until now. I was thinking of moving over to inode watcher tools like entr or something. So I was excited to see that you were focusing on this feature.

However, this doesnt seem to work for me on ArchLinux. The manual mode seemed to create commits but didnt push to the remote. I saw this error.

gpg-agent[2775]: scdaemon[8002]: apdu_open_reader: failed to open driver 'libpcsclite.so.1': libpcsclite.so.1: cannot open shared object file: No such file or directory

I installed the pcsclite package and this seemed to solve the manual mode issue to some extent. When i check the systemd status of the daemon I see this error.

systemd[3395]: Background Process for Auto Syncing Git Repos was skipped because of a failed condition check (ConditionFileIsExecutable=/usr/bin/git-auto-sync-daemon)

The gpg-agent is still not completely silent. I have these errors still lurking.
gpg-agent[8000]: scdaemon[8000]: pcsc_establish_context failed: no service

Can you help me troubleshoot this?

Deamon registration fails on Windows 11

I ran git-auto-sync d add <repo> and I am getting:

Installing git-auto-sync as a daemon
Starting git-auto-sync-daemon
2022/05/15 13:54:16 The dependency service does not exist or has been marked for deletion.

I checked for the process called git-auto-sync-daemon, but there is none.

I am using git-auto-sync on Windows 11 and manual synchronization works.

"git-auto-sync-daemon is NOT Running!"

macOS Monterey 12.5, M1 Mac

I've set up git-auto-sync and it has successfully synced my repo, then I added the repo to the daemon. When I run git-auto-sync daemon status I receive the following message:

git-auto-sync-daemon is NOT Running!
Monitoring -
   /my/chosen/directory

How do I get the daemon to start?

daemon: "the service is not installed"

Hi Vishesh,

I just installed git-auto-sync on my Ubuntu 22.04.1 LTS as described in the Installation section for Ubuntu/Debian. Installation worked without issue.

I added a couple of respositories I want to sync using git-auto-sync:

❯ git-auto-sync daemon add /home/me/src/ppp/repo1
Installing git-auto-sync as a daemon
Starting git-auto-sync-daemon
❯ git-auto-sync daemon add /home/me/src/ppp/repo2
Starting git-auto-sync-daemon
❯ git-auto-sync daemon add /home/me/src/ppp/repo3
Starting git-auto-sync-daemon
❯ git-auto-sync daemon add /home/me/src/ppp/repo4
Starting git-auto-sync-daemon
❯ git-auto-sync daemon ls
/home/me/src/ppp/repo1
/home/me/src/ppp/repo2
/home/me/src/ppp/repo3
/home/me/src/ppp/repo4
❯ git-auto-sync daemon status
2022/08/29 12:02:50 the service is not installed

As a result of the daemon not running, the repos are not synchronised.

Is there anything I am doing wrong or is there any prerequisite bevor installing git-auto-sync?

Regards
Peer

Unusable for Average User

Hi,

Many thanks for designing this script but it seems unusable for an average PC user. I am getting these errors when trying to run the .sh script in the terminal and get git to work. Not to mention the .plist file which I don't even know how to run on my Linux system.

A simple GUI app that would monitor file changes and autosync would be a much needed addition to the GitJournal project, in my view.

user@pc ~/ . . . /GitJournal $ bash git-auto-sync.sh 
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
user@pc ~/ . . . /GitJournal $ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in / . . . /GitJournal/.git/

When does the daemon sync?

Windows 10 user here:

After making sure that git-auto-sync sync works. I used the "daemon add" command to add my repository. Using "daemon status" shows:

git-auto-sync-daemon is Running!
Monitoring -
   "FOLDER_PATH"

Looks like everything is working fine, however when checking the actual repo, changes are not being synced at any moment even after waiting a few hours.
From the README.md I though this runs every 10 minutes but it doesn't look like it. When does it call sync exactly?

Doesn't sync if on previously repo was unaccessible

Steps to reproduce:

  • disconnect from VPN (I guess simple internet disconnect would do too)
  • change any file
  • call git-auto-sync sync
    • it should give an error accessing remote repository
  • connect VPN
  • try git-auto-sync sync

Expect: retry: git add; git commit; git pull; git push
Observed: nothing to commit -> stops even though local is 1 commit ahead of remote

➜  git-auto-sync --version
git-auto-sync version 1.5

➜  git-auto-sync sync
2024/04/30 16:23:23 exit status 128: Command: git fetch origin
StdOut:
StdErr: ssh: Could not resolve hostname gerrit.int.COMPANY.com: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
➜  git-auto-sync sync
2024/04/30 16:23:51 exit status 1: Command: git commit -m  D rust/ripgrep-all
 D rust/rustlings
 D tools/clink/clink-completions
StdOut: On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

StdErr:
➜ 

Consistent command line options

For the sake of consistency I would assume the use of hyphens for command line parameters. Egs.: --sync and -s for the synchronization command over sync and s. Similar to --help and -h.

Sync started failing on macOS Monterey

I set up auto-sync a few months ago (for some shared Org mode files) and it seemed to be running well since then. However, late last month it seems to have silently stopped working, perhaps due to some sort of software update. git auto-sync daemon add . and all other daemon commands seem to work fine, indicating that the repo is registered to synchronize and the daemon is running, but it doesn't actually make commits or push them. git auto-sync sync . fails with the cryptic error 2022/11/17 16:07:08 invalid checksum. I vaguely remember having some minor difficulties recently getting gpg and git to work correctly again after some changes, but AFAIK that's all working fine now (and manually committing and pushing from the synchronized directory has no problems).

Where would I find more troubleshooting information?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.