【问题标题】:git failed in Qt creatorgit 在 Qt 创建者中失败
【发布时间】:2015-12-01 00:02:08
【问题描述】:

我正在使用 gitlab 来管理我的代码。

当我使用 git bash 管理我的代码时,它可以成功提交并将代码推送到服务器。

我在 git bash 中使用的代码如下:

git add .
git commit
git push -u origin master

但是,当我在 Qt creator 中提交项目时,作者信息不会自动填写。

( click here for the capture image 1)

另外,我在 Qt creator 的 git 选项中点击 push。如:

(click here for the capture image 2)

发送代码到服务器失败,错误信息如下:

14:20 Executing in H:\0000ybzhao\Programming\00.git\pairSam2Bed: C:\Program Files\Git\bin\git.exe push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
The command "C:\Program Files\Git\bin\git.exe" terminated with exit code 128.

有没有人知道为什么会发生这种情况或如何解决这个问题?

提前致谢。

【问题讨论】:

    标签: git qt github gitlab


    【解决方案1】:

    您可能需要使用用户名和电子邮件地址在计算机上初始化 git。

    https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

    $ git config --global user.name "John Doe"
    $ git config --global user.email johndoe@example.com
    

    其他关于在 Windows 中使用 Git 的方法

    我会考虑安装和使用 Atlassian 的 SourceTree。它确实使管理 git repos 变得简单而直观。另一个适用于 Windows 的简洁工具是 p4merge,可用于在 git 存储库上进行合并和冲突解决。

    在 Windows 上安装这些工具的最简单方法:

    1. Install Chocolatey 在管理员命令提示符下。
    2. 在管理员命令提示符下运行 choco install P4Merge SourceTree -y
    3. 打开源代码树,按照提示操作(跳过 Mercurial 的内容)。
    4. 在选项中添加P4Merge作为外部合并工具。

    希望对您有所帮助。

    【讨论】:

    • 感谢您的回复。实际上,我已经在我的计算机上使用用户名和电子邮件初始化了 git。我发现最主要的原因是“主机密钥验证失败。致命:无法从远程存储库读取”。我会继续尝试您的附加响应。
    • 根据主机的不同,您需要创建一个公钥并将其安装在您的计算机上,或者删除旧的主机密钥。 SourceTree 使这非常轻松。 doc.gitlab.com/ce/ssh/README.html如何删除旧主机密钥stackoverflow.com/questions/13363553/…
    【解决方案2】:

    在终端中使用

    git push --set-upstream origin master
    

    之后你的 Qt 会好起来的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-21
      • 2014-05-25
      • 1970-01-01
      • 1970-01-01
      • 2016-02-11
      • 2012-12-13
      • 2013-07-09
      相关资源
      最近更新 更多