Search code examples
gitcygwin

git woes: create repo with file access with cygwin


Working with cygwin git. --version reports 2.17.0. Have a share, and have been using existing repos successfully. Needed to create a new repo, and created it:

cd /cygwin/y/path/to/repos
mkdir newrepo.git
git init --bare

then left the share back to where I work and:

cd /cygwin/c/path/to/sources
mkdir newrepo
cd newrepo
git init
git remote add origin /cygwin/y/path/to/repos/newrepo.git
cp ../.gitignore ./
git add .gitignore 
git commit -m "Set up the repo"
git push -u origin master

As I've done before (although this may be the first time with cygwin). It then emits:

Counting objects: 3, done.
Writing objects: 100% (3/3), 249 bytes | 83.00 KiB/s,    done.
Total 3 (delta 0), reused 0 (delta 0)
remote: fatal: not a git repository: '.'
fatal: not a git repository: '.'
To /cygwin/y/path/to/repos/newrepo.git/
 ! [remote rejected] master -> master (missing necessary objects)
error: failed to push some refs to '/cygwin/y/path/to/repos/newrepo.git/'

git remote -vv shows:

origin /cygwin/y/path/to/repos/newrepo.git/ (fetch)
origin /cygwin/y/path/to/repos/newrepo.git/ (push)

and .git/config looks like:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "origin"]
        url = /cygdrive/y/path/to/repos/newrepo.git/
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

My google-fu with the error message only turns up things about the scripts for working with git's behavior. Have never needed this, and never touched it. For an attempt at completeness, issuing "env | grep -i git" doesn't turn up anything.

I also went through the process of cloning the bare repo instead of creating the directory and "init/remote add" with the same results. Also used the file:// nomenclature. All produced the same results.

So, why is "." not a git repo? And how is it even getting to that point?

EDIT: Has something to do with the repo being on a shared drive. Tried all this again on a local drive (/cygdrive/c/path/to/repo/ instead of /cygdrive/y/path/to/repo/) and it works fine.


Solution

  • Answering my own question, since my google-fu still can't find anything, and I found a workable (though klunky) work-around.

    Installed the git for windows (or whatever it's called--uses mingwwin) thingee. Creating the repo with this ('git init --bare ') in the shared directory. Used cygwin to clone and repopulate the source tree. Looks to work. Have checked code in and cloned on different machines with cygwin, and all is good.

    For reference, git for windows reports:

    $ git --version
    git version 2.19.1.windows.1
    

    cygwin's git reports:

    $ git --version
    git version 2.17.0