Search code examples
windowsgitshellgit-remote

Git Files not being pushed to remote repository [Windows]


So I'm just learning Git, and can't tell what I'm doing wrong in setting up a local and remote repo for my scripts. Originally, the remote repo was going to live on a fileshare (\server\share$\scripts), but I can't even seem to get this to work on my local machine.

I've done my research, and read up on some of the common pitfalls, but I still can't seem to get files accurately reflected in my remote repo when pushing from the local one.

What I have:

Local Repo: In C:\git, with one file "test.txt" created by:

cd C:\git
git init
echo "Hello World" > test.txt
git add .
git commit

Remote Repo: C:\test

git --bare init

Then, when I specify a remove branch with:

git remote add origin C:\test
git push origin master

It tells me all is fine:

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 315 bytes | 315.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To C:\test
   06e076a..62b6130  master -> master

And further git pushes return "Everything up-to-date", but the files are never pushed to the remote repository. Querying the logfile indicates that the push did in fact take place:

commit 62b6130cedef529ef97aec5333fcbee96c5e9a2f (HEAD -> master)
Author: [Redacted]
Date:   Wed Jan 24 15:21:37 2018 -0500
TEST COMMIT

So where are the files? I'm on the right branch (master), and I even ran a git config receive.denyCurrentBranch false because some other similar threads suggested this as a fix.

Looking for some guidance here, appreciate any and all help!


Solution

  • Your remote repository is a bare repository. This means there simply is no checked out working tree. Just the git objects and branches and tags.

    Having a working tree (aka your files in the most up to date master branch) doesn't make any sense for a remote repository. This is where you store all versions of all your files in one place. How should git know which branch/version/commit to use in the working tree?

    I also found this description: Source

    • git init is for working
    • git init --bare is for sharing

    To get your files back again, you need to clone from there.

    git clone C:\test .
    

    This will create a new repository with working tree.

    Here are some links: