Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Having second repository for syncing is easier than this #5

@Ciantic

Description

@Ciantic

Sync git maybe done more neatly with having two repositories:

  • One for regular development the .git directory in the project root.
  • One for continuous commits / syncing .gitsync directory in project root.

The alternate repositories can be achieved with env variables:

  • $GIT_DIR - This tells Git where to look for the .git directory. In this way you could be in /tmp/whatever and manage your git repository located in /home/grahamc/my-awesome-files.
  • GIT_WORK_TREE - This tells Git where the files are that it is tracking. Using this your .git directory could be in /tmp/whatever and actually have all your checked out files be put in to /home/grahamc/my-awesome-files.

So each continuous / sync committing just uses different $GIT_DIR for that commit call.

Shamelessly copied from "How to have two git repositories in the same directory", there is also script git-multi by grahamc that helps maintaining the alternate repositories.

Update: (I wanted to give example)

In Windows you can init two repositories on same dir just by:

set GIT_DIR=.gitsync
git init
set GIT_DIR=
git init

now you have two repositories .git and .gitsync, that's kinda neat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions