【问题标题】:Gitea can't fetch repositoriesGitea 无法获取存储库
【发布时间】:2017-08-05 08:17:25
【问题描述】:

我在我的树莓派上安装了 gitea(如果有人不知道,它是 gogs 的开源分支)。我在用户 pi 和用户 git 下尝试过。在用户 pi 中,gitea 安装在 /home/pi/gitea 中,而在 git 中,它安装在 /home/git 中。在这两种情况下,存储库目录都位于安装根目录中。

我使用 webui 创建了一个新的存储库,并尝试了 2 个远程安装。

rpilocal = pi@192.168.1.125:/home/pi/gitea/repositories/uname/repositoryname
rpilocal2 = pi@192.168.1.125:uname/repositoryname
rpigitlocal = git@192.168.1.125:/home/pi/gitea/repositories/uname/repositoryname
rpigitlocal2 = git@192.168.1.125:uname/repositoryname/repositoryname

当我尝试推送 rpilocal2rpigitlocal2 时,我收到以下错误消息:

git push rpigitlocal2 master
git@192.168.1.125's password: 
fatal: 'feralheart/leltar.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

当我尝试使用 rpilocalrpigitlocal 推送时,推送成功,但在 web 界面中,我仍然看到“使用 CLI 创建新存储库或推送现有存储库”。

怎么了?

【问题讨论】:

    标签: linux git raspberry-pi gitea


    【解决方案1】:

    我在 VPS 上使用 gitea 的测试设置,遇到了可能是同样的问题。在进行了各种测试之后,我发现了一个对我有用的解决方法。如果它可以帮助...

    什么已经在工作了

    就我而言,要求gitea 创建一个带有初始“自述文件提交”的新git 存储库工作正常。我可以clone,添加新提交和push。新提交出现在 gitea Web UI 中的第一个提交之后。

    什么不工作

    如果我要求 gitea 在没有初始提交的情况下创建存储库gitea 的 Web UI 将不会反映提交历史的推送,即

    user@client:~/projects$ mkdir myCode
    user@client:~/projects$ cd myCode
    user@client:~/projects/myCode$ git init
    Initialized empty Git repository in /home/user/projects/myCode/.git/
    user@client:~/projects/myCode$ echo "testing 1 2 3" > file.txt
    user@client:~/projects/myCode$ git add file.txt
    user@client:~/projects/myCode$ git commit -m0
    [master (root-commit) f9d8e7] 0
     1 file changed, 1 insertion(+)
     create mode 100644 file.txt
    user@client:~/projects/myCode$ git remote add origin git@server:gitea_repos/owner/myCode.git
    user@client:~/projects/myCode$ git push -u origin master
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 210 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@server:gitea_repos/owner/myCode.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
    user@client:~/projects/myCode$ 
    

    git 将报告成功,git@server:gitea_repos/owner/myCode.git 将继续充当远程,但 gitea Web UI 将继续显示“空存储库”帮助页面而不是存储库浏览器.

    变通策略

    因为新提交注册在开始非空的存储库上,it occurred to me gitea 可能会注意到如果git 用另一个项目的完整提交历史覆盖了新项目的存根提交历史记录的变化。要尝试此操作,请遵循:

    3 个简单步骤:

    1. gitea Web UI 中,创建一个新的存储库。在New Repository 创建页面上,请务必选中Initialize this repository with selected files and template 旁边的框,然后再单击Create Repository
    2. 在您的工作站上,将此新存根作为 remote 添加到具有所需提交历史记录的本地 git 存储库。

      user@client:~$ cd projects/myCode
      user@client:~/projects/myCode$ git remote add gitea git@server:gitea_repos/owner/myCode.git
      
    3. 用预期的材料覆盖gitea-生成的存根提交。

      user@client:~/projects/myCode$ git push -fu gitea master
      Counting objects: 97, done.
      Delta compression using up to 32 threads.
      Compressing objects: 100% (95/95), done.
      Writing objects: 100% (97/97), 55.53 KiB | 0 bytes/s, done.
      Total 97 (delta 45), reused 0 (delta 0)
      To git@server:gitea_repos/owner/myCode.git
       + a1b2c3...d4e5f6 master -> master (forced update)
      Branch master set up to track remote branch master from gitea.
      user@client:~/projects/myCode$ 
      

    请注意,对于第 3 步:

    • -f 用于强制:这使git 能够执行(否则禁止)“提交树覆盖”
    • -u 用于 set-upstream - 这会将本地分支 master 通过远程跟踪分支 gitea/master 连接到由 gitea 管理的主分支

    跟进

    这个策略有点像黑客,我怀疑它会留下一些未完成的事情。例如。您可能希望将分支和标签推送到gitea。 (我的测试还没有到这一步。)考虑--all 用于分支和--tags 用于标签:

    user@client:~/projects/myCode$ git push gitea --all
    user@client:~/projects/myCode$ git push gitea --tags
    

    YMMV 期间,祝你好运!


    脚注:

    - 我正在与gitea-1.4.2-linux-amd64 合作,在Ubuntu 16.04.2 LTS 上托管在virmach.com

    - git 在引用没有提交的存储库时使用术语“空存储库”,但在 gitea 用于访问 git 功能的内部 API 中(以及,偶尔,gitea 社区成员)使用术语“裸存储库”

    - git 使用术语“裸存储库”指代一个存储库嵌入(作为目录./.git)在一个根目录中“工作树”。裸存储库经常用作协作的规范副本,并存储在服务器上(并可从服务器访问)。例如。 “github”服务。有时这些目录使用架构project_name.git 命名

    - 我尝试了许多设置变化,在irc 频道#gitea 上四处询问,并在代码中四处寻找。我所能得出的结论是,git→hooks→gitea 链中的一些差异(在空存储库和非空存储库之间变化)是我 VPS 上出现此问题的原因。

    - 在此之前,我曾想过在新的存根上重放所需项目的历史,但这个 rebase 操作是一个绝望的 hack:所有提交都得到新的 sha 校验和和,本质上,所有开发人员都必须再次克隆,就像在新存储库上工作一样。

    【讨论】:

      猜你喜欢
      • 2019-07-09
      • 2019-12-25
      • 1970-01-01
      • 2022-01-14
      • 2015-10-13
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-12-16
      相关资源
      最近更新 更多