【问题标题】:Xcode 9.2 Unable to configure git source control for master branchXcode 9.2 无法为 master 分支配置 git 源代码控制
【发布时间】:2018-08-27 14:50:46
【问题描述】:

我创建了一个新的 Xcode 项目,并选择了以下选项:

经过一些编码后,我进入源代码控制菜单并选择了提交。 提交文件后,我的主分支也不可见

我需要添加一个远程仓库并将这个 xcode 项目推送到 github 仓库。

我已经尝试了所有这些解决方案:

Raywenderlich

Appcoda

All answers from this stackoverflow link too

可能是什么问题?我第一次使用 git 版本控制,所以无法弄清楚缺少什么。

编辑 使用@VonC 解决方案:

使用命令行推送时出现此错误:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/xia.....'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

编辑 2:

这是我在 github 页面上的分支:

【问题讨论】:

    标签: xcode git github


    【解决方案1】:

    切换回命令行以了解更多信息:

    cd /path/to/my/local/repo
    git status
    

    如果你看到一个主分支,检查远程

    git remote -v
    

    如果你没有看到:

    git remote add origin /url/github/empty/repo
    
    git fetch
    git branch -u origin/master master
    git pull --rebase
    
    git push -u origin master
    

    由于master 现在与origin/master 关联,下一次推送将只是git push

    【讨论】:

    • 分支master和remote正确
    • @Mamta 还有 git push?
    • 我编辑了问题。无法在 push 命令上推送一些 refs
    • @Mamta 先做一个git pull --rebase,然后是git push
    • @Mamta 一个简单的 git push 就足够了:您的本地 master 分支现在与 origin/master 关联。
    猜你喜欢
    • 2021-02-03
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    • 2013-09-17
    • 2017-11-25
    • 1970-01-01
    • 2011-09-09
    相关资源
    最近更新 更多