【问题标题】:Git Push worked, but files are not on serverGit Push 工作,但文件不在服务器上
【发布时间】:2013-06-23 00:37:05
【问题描述】:

我在我的 HostGator 共享帐户上设置了一个 git,我刚刚进行了第一次推送。但是,当我在服务器上查看文件时,文件不存在 - Push 没有抛出任何错误或表示任何错误。

如果这有什么不同,我正在使用 SSH 类型的连接。我跟着this guide 建立了一个git repo。据我所知,远程源 URL 是正确的。

本地 LS:

/Applications/MAMP/htdocs/cyclesafestl [master] $ ls

/Applications/MAMP/htdocs/cyclesafestl
total 32
-rw-r--r--@ 1 503  80    81 Jun 19 10:49 BETA.txt
-rw-r--r--  1 503  80  1772 Jun 18 23:11 index.php
-rw-r--r--@ 1 503  80   616 Jun 18 22:49 info.txt
drwxr-xr-x  7 503  80   238 Jun 17 22:59 includes/
-rw-r--r--  1 503  80    76 Jun 17 16:18 README.md

服务器 LS:

./
../
HEAD
branches/
config
description
hooks/
info/
objects/
refs/

Git 推送信息:

/Applications/MAMP/htdocs/cyclesafestl [master] $ git push -u origin master
Counting objects: 45, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (45/45), 498.12 KiB, done.
Total 45 (delta 1), reused 0 (delta 0)
To ssh://xxx@thehivestl.com:xxx/home2/xxx/public_html/thehivestl.com/cyclesafestl
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

【问题讨论】:

    标签: git ssh push git-push


    【解决方案1】:

    完成推送后。在远程服务器上运行以下命令之一,

    git reset --hard
    

    git stash
    

    【讨论】:

      【解决方案2】:

      文件在那里,您只是看不到它们,因为它们嵌入到 Git 数据库中。这是使用--bare 或不使用git-init man page 初始化存储库之间的区别(请参阅git-init man pagethis page)。在服务器端,您只能看到通常的 .git 文件夹的内容,您应该在该文件夹中看到您的项目。尝试在另一个目录中再次克隆相同的存储库,如果您可以检索您的修改,那么您的设置工作正常。

      【讨论】:

      • 好点!我尝试克隆并且文件在那里,但是我希望在我的服务器上使用它作为一种暂存平台,所以我可以推送和测试以及推送和测试我所有的 mysql 数据库。但是当我转到相对 URL 时,我无法查看该页面。我应该用 git init 重新创建页面并删除 --bare 吗?
      • 我建议把事情分开。此存储库用于备份。如果您想设置一个暂存平台,更好的解决方案是将存储库克隆到另一个目录并使用 git hooks 以使其保持最新。
      • 所以我可以在我的服务器上的暂存目录中克隆这个 repo,git hooks 有什么帮助?我可以设置一个挂钩来通知文件何时被推送并在暂存目录中保持最新状态?
      • 一个简单的解决方案是将您的 post-receive 挂钩(请参阅git-scm.com/book/en/Customizing-Git-Git-Hooks)设置为“cd $staging-dir && git pull origin master”之类的东西
      • 您能否提供一个关于如何显示文件的描述性解决方案。这个解释是有道理的,但并没有给我一个出路。
      猜你喜欢
      • 2012-01-16
      • 1970-01-01
      • 2016-02-21
      • 2020-01-10
      • 2017-12-06
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      相关资源
      最近更新 更多