【问题标题】:Git Config file and setup not allowing pull from github and push to dreamhostGit 配置文件和设置不允许从 github 拉取并推送到 dreamhost
【发布时间】:2021-10-21 11:47:30
【问题描述】:

.git/config

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@github.com:myusername/wp-theme.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
    remote = dreamhost
    merge = refs/heads/main
[remote "dreamhost"]
    url = ssh://myusername@server.domain.com/~/my.domain.com.git
    fetch = +refs/heads/*:refs/remotes/dreamhost/*

我很难从 github 中提取代码并将其推送到我的 dreamhost 服务器。

我运行(在我的本地计算机上)...

 git push -u dreamhost main

然后运行(在服务器上)..

git clone ~/my.domain.com.git ~/cloned.my.domain.com.git

但是文件夹是空的。我做错了什么?

【问题讨论】:

    标签: git github ssh


    【解决方案1】:

    在您的空克隆存储库文件夹~/cloned.my.domain.com.git 中,检查以下输出:

    git branch -avv
    

    想法是:您的本地计算机可能有一个最近的 Git,默认分支为 main
    虽然您的目标裸存储库 (~/my.domain.com.git) 可能具有默认分支 master

    如果您推送 main 分支,但在目标端克隆默认的 master 分支,后者将没有提交/文件可显示。
    您需要返回裸存储库 (~/my.domain.com.git) 和 change its default branch

    如果origin/main 存在:

    git checkout main
    

    【讨论】:

    • 我得到“ remotes/origin/main 8a1c8e0 Commit for add all wp files”,所以它看到了最后一个 git commit,但不显示文件。如果我只做“git branch”,它什么也不会显示。
    • @user2012677 然后以git switch -c main 开头,看到文件都恢复了。
    • 得到这个错误:“git: 'switch' 不是 git 命令。参见 'git --help'。”
    • @user2012677 干得好。如果你升级 git,你会得到 git switch,比 checkout 更容易混淆:stackoverflow.com/a/57066202/6309 (Git 2.23, Q3 2019)。
    猜你喜欢
    • 2010-12-27
    • 2015-10-25
    • 2015-05-20
    • 1970-01-01
    • 2022-12-21
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 2021-09-08
    相关资源
    最近更新 更多