【问题标题】:git: Can't add files to githubgit:无法将文件添加到 github
【发布时间】:2015-07-18 12:44:36
【问题描述】:

我发现了一些类似的问题。但我找不到解决办法。

我使用以下方法将包含文件和子文件夹的文件夹添加到本地存储库:

git add .

然后用:

git commit -m "comment"

我明白了:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

问题是,我在 github 上找不到文件。有什么想法吗?

编辑:

git push -u git@github.com:kamekame/wolke master

给予:

To git@github.com:kamekame/wolke
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:kamekame/wolke'
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.

解决方案:

git remote -v

给我:

origin  git@github.com:kamekame/alpha.git (fetch)
origin  git@github.com:kamekame/alpha.git (push)

这与我的推送地址 kamekame/wolke 不同!

【问题讨论】:

标签: git github add


【解决方案1】:

您需要设置本地存储库以将上游推送到您的 github 存储库。 来自:https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line

您的下一步将是:

# create repo via github ui or github cli

# add github as the origin
git remote add origin remote_repository_URL

# push changes to repo
git push origin master

【讨论】:

  • git remote add origin github.com/kamekame/wolke --> 致命:远程源已经存在。
  • git push origin master --> 一切都是最新的
  • 你是说文件仍然没有推送?通过git remote -v 检查您的原始远程。如果远程 url 看起来不正确,您可以使用git remote set-url origin url 重置它。此外,如果设置正确,您应该能够毫无错误地拉取。
猜你喜欢
  • 2020-04-16
  • 1970-01-01
  • 2019-07-21
  • 2016-10-31
  • 1970-01-01
  • 2020-02-11
  • 1970-01-01
  • 1970-01-01
  • 2021-12-21
相关资源
最近更新 更多