【问题标题】:Why do git commits exist on my local clone/directory but not on GitHub?为什么 git 提交存在于我的本地克隆/目录中,但不存在于 GitHub 上?
【发布时间】:2014-07-28 22:30:38
【问题描述】:

我已经在命令行上使用 git 为一个项目提交并推送了多项更改,但是当我登录 GitHub 时,我所做的分支和提交并没有显示在我的帐户上。为什么?

我可以在命令行上查看我使用 git 所做的所有提交历史记录。

git remote -v 命令的结果

origin  https://github.com/felixtan/guessing-game.git (fetch)
origin  https://github.com/felixtan/guessing-game.git (push)

【问题讨论】:

  • 你添加了github作为远程吗?从命令行尝试 git remote -v 并将结果发布到问题中。
  • 它是您的存储库吗?当您尝试 git push origin <branchname> 为您所称的分支机构提供什么时,它说了什么?
  • 确保如果您使用的是非默认分支,请使用 git push ORIGIN_NAME BRANCH_NAME -u 将其标记为先跟踪。

标签: macos git command-line github


【解决方案1】:

一旦在本地提交,您仍然需要将这些提交推送到 github:

git push

(因为你的遥控器被命名为origin,所以你不需要指定它的名字:它默认推送到'origin')

这假设您是 repo felixtan/guessing-game 的所有者或 one of the collaborators

如果是第一次推送当前分支:

git push -u origin yourCurrentBranch

在您的分支和“origin/yourBranch”之间建立跟踪关系,详见“Why do I need to explicitly push a new branch?”。

第一次推送完成后,后续推送就是简单的“git push”。


如果您不是所有者/合作者,您将无权推送到该仓库。

你需要make a fork(参见GitHub forking),并且在你的本地克隆仓库中你已经在处理:

git remote rename origin upstream
git remote add origin https://YourLogin@github.com/YourLogin/guessing-game.git

这样,您将推送到您的分叉(您拥有的),并生成pull requests from there(请参阅GitHub pull requests)。

【讨论】:

    猜你喜欢
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    • 2014-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 2019-05-09
    相关资源
    最近更新 更多