简体   繁体   English

git push to remote:提交正在执行,但是看不到文件?

[英]git push to remote: commits are going through but can't see files?

i have set up a bare repo on a remote server and can push to it but i am not seeing any files on the remote when i'm finished.... this is what I'm seeing when i push: 我已经在远程服务器上设置了一个裸仓库,可以推送到它,但是我完成后在远程服务器上看不到任何文件...。这是我在推送时看到的:

my-macbook-pro:myapp me$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   www/index.php
#
no changes added to commit (use "git add" and/or "git commit -a")
my-macbook-pro:myapp me$ git add .
my-macbook-pro:myapp me$ git commit -m 'test'
[master 57e4b86] test
 1 files changed, 2 insertions(+), 1 deletions(-)
my-macbook-pro:myapp me$ git push
me@myapp.com's password: 
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 368 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
To ssh://me@myapp.com:1111/var/www/myapp.git
   ce07e61..57e4b86  master -> master
my-macbook-pro:myapp me$ 

when i ssh in, the files i've "pushed" are not there. 当我ssh进入时,我“推送”的文件不存在。 any ideas? 有任何想法吗?

As already mentioned by Krelin and Ray, a bare repository will not contain the files themselves. 如Krelin和Ray所提到的,裸仓库将不包含文件本身。 This is a feature, not a bug, as it avoids potential confusion down-the-road. 这是一个功能,而不是错误,因为它避免了日后的潜在混乱。 However, this feature makes a simple push unusable if, for example, you want to update your website on a server. 但是,例如,如果您想在服务器上更新网站,此功能将使简单的推送不可用。

One solution is to push to a repository on your server and then use hooks to automatically update the files in the target folder. 一种解决方案是推送到服务器上的存储库,然后使用挂钩自动更新目标文件夹中的文件。 Digital Ocean has a nice tutorial explaining how to do his here: Digital Ocean有一个很好的教程,解释了如何在此处进行操作:

https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

You're not supposed to see files, you're supposed to see revisions. 您不应该看到文件,您应该看到修订。 Besides, you have a bare repository on remote which doesn't have a working directory at all. 此外,您在远程上有一个裸仓库,根本没有工作目录。

You can do something like git branch , git show master , git log and some such to examine repository content. 您可以执行git branchgit show mastergit log等操作来检查存储库内容。

A bare repository is a repository that doesn't have a working directory. 裸存储库是没有工作目录的存储库。 You can tell it because what would "normally" be inside the .git folder is right there in the directory, and the directory itself is named with a ".git" suffix. 您可以说出来,因为.git文件夹中的内容通常位于目录中,而目录本身的后缀为.git。

The point of that is, you wouldn't want to overwrite somebody's changes by pushing into a working directory they're working in. So you have a central check-in repository that everyone shares their changes to that is bare--a repo only, no working directory. 关键是,您不想通过将某人的更改推送到他们正在工作的工作目录中来覆盖它。因此,您有一个中央签入存储库,每个人都共享对它们的更改,而这仅仅是一个回购协议,没有工作目录。 Eliminates any risk of that. 消除任何风险。

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

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