There is ~/work/project and ~/Dropbox/ , in which project → ~/work/project .

In the ~/work/project folder, the .git folder is in ~/work/project-git

So, how can you still call git in ~/work/project without creating a symlink?

Simlink cannot be used as dropbox will copy all the contents. Maybe he can somehow say not to do this?

    1 answer 1

    address to the directory with the repository (if it is not in the .git directory in the root of the project) in different ways.

    in your case, addressing with a .git file is .git , as described, for example, in this answer .


    show by example:

    • the workdir you want to keep in the directory /путь/к/проекту
    • and you want to keep the storage ( gitdir ) in the directory /путь/к/хранилищу

    1. make the current directory /путь/к/проекту :

       $ cd /путь/к/проекту 
    2. initialize the repository:

      • for git program version 1.7.5 or higher :

         $ git --separate-git-dir /путь/к/хранилищу init 

        A full-fledged /путь/к/хранилищу will be created in the directory /путь/к/хранилищу with all the necessary files / directories: branches , config , description , etc., and a .git file will be created in the current directory with a “reference” to the repository location, with the following content:

         gitdir: /путь/к/хранилищу 
      • for the git program below version 1.7.5, it will be necessary to do the described in semi-manual mode:

         $ git --git-dir=/путь/к/хранилищу --work-tree=. init $ echo "gitdir: /путь/к/хранилищу" > .git 

    If the repository already exists in the .git directory in the root of your project, you will need to do the following:

    1. make current directory /путь/к/проекту

       $ cd /путь/к/проекту 
    2. set explicitly in the storage configuration the path to the working directory:

       $ git config core.worktree /путь/к/проекту 
    3. Move the .git directory to the desired location with the desired name (the target directory /путь/к/хранилищу should not exist at this moment, otherwise the storage files / directories will go to /путь/к/хранилищу /путь/к/хранилищу/.git ):

       $ mv .git /путь/к/хранилищу 
    4. create a .git file in the current directory:

       $ echo "gitdir: /путь/к/хранилищу" > .git