简体   繁体   English

Git文件未推送到远程存储库[Windows]

[英]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. 所以我只是在学习Git,而无法告诉我在为脚本设置本地和远程存储库时做错了什么。 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. 最初,远程回购协议将驻留在文件共享(\\ server \\ share $ \\ scripts)上,但我什至无法在本地计算机上使用它。

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: 本地存储库:在C:\\ git中,通过以下方式创建一个文件“ test.txt”:

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

Remote Repo: C:\\test 远程仓库: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. 进一步的git pushes返回“一切都是最新的”,但是文件永远不会被推送到远程存储库。 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. 我在右分支(主git config receive.denyCurrentBranch false )上,甚至运行了git config receive.denyCurrentBranch false因为其他一些类似的线程建议将此作为修复。

Looking for some guidance here, appreciate any and all help! 在这里寻找一些指导,感谢所有帮助!

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. 只是git对象以及分支和标签。

Having a working tree (aka your files in the most up to date master branch) doesn't make any sense for a remote repository. 具有工作树(也就是您的文件位于最新的master分支中)对于远程存储库没有任何意义。 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? git应该如何知道在工作树中使用哪个分支/版本/提交?

I also found this description: Source 我也找到了以下描述: 来源

  • git init is for working git init用于工作
  • git init --bare is for sharing git init --bare用于共享

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: 以下是一些链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM