git 说它提交了,但在 GitHub 中它没有出现

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32315833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:19:41  来源:igfitidea点击:

Says it commits, but in GitHub it doesn't show up

gitgithub

提问by JonnyDoeInWisco

I just installed rails on an Ubuntu machine. I set up git and made an ssh key to link to my account. I made a repository to commit to, and made a sample project to test with called first_app. When I make commits it says it was all committed, but I go to github and it isn't there. I want to put my project up there, but it doesn't have the connection for some reason. I've googled around and I'm not seeing anything so it must be some stupid thing I did. Is there a way I can check that everything is configured right?

我刚刚在 Ubuntu 机器上安装了 rails。我设置了 git 并制作了一个 ssh 密钥来链接到我的帐户。我制作了一个要提交的存储库,并制作了一个名为 first_app 的示例项目进行测试。当我提交时,它说它已全部提交,但我去了 github 并且它不在那里。我想把我的项目放在那里,但由于某种原因它没有连接。我用谷歌搜索了一下,没有看到任何东西,所以这一定是我做的一些愚蠢的事情。有没有办法可以检查一切是否配置正确?

Edit: Tried to set the remote address, but it was already right. It has the correct URL.

编辑:尝试设置远程地址,但已经正确。它有正确的 URL。

Edit2: Here is what came up in the terminal:

Edit2:这是终端中出现的内容:

jonny@MM061-JD:~/first_app$ cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = [email protected]:JonnyDoeInWisco/first_app.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
jonny@MM061-JD:~/first_app$ git remote -v
origin  [email protected]:JonnyDoeInWisco/first_app.git (fetch)
origin  [email protected]:JonnyDoeInWisco/first_app.git (push)

采纳答案by Thomas Stringer

You have to push your commits from your local repository to the remote repository:

您必须将提交从本地存储库推送到远程存储库:

$ git commit -m "your commit message"

$ git push origin <branch_name>

Substitute <branch_name>with the remote branch you are pushing to (i.e. masterbranch would be $ git push origin master).

替换<branch_name>为您推送到的远程分支(即master分支为$ git push origin master)。

Withoutpushing your commit, you should see a similar message when you run:

推送提交的情况下,运行时应该会看到类似的消息:

$ git status

Git will tell you that you have commits that you need to pushto your remote.

Git 会告诉你你有需要提交push到远程的提交。

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

Verify your remote repositories

验证您的远程存储库

If you are seeing an up-to-date status with your remote, you should verify you're actually pushing to the location/repo that you think you are:

如果您看到遥控器的最新状态,您应该验证您实际上正在推送到您认为的位置/存储库:

$ git remote -v

回答by ddavison

You need to push your commits.

您需要推送您的提交。

Try:

尝试:

$ git push origin master

The reason for this, is because when you make a commit, it actually just commits to your "local repository".

这样做的原因是,当您进行提交时,它实际上只是提交到您的“本地存储库”。

Read moreon the difference between commits and pushes.

阅读有关提交和推送之间区别的更多信息。

回答by alcfeoh

With Git, you have to commit then push your changes. A commit is a local operation, while pushing actually sends your file to the remote repository.

使用 Git,您必须提交然后推送您的更改。提交是本地操作,而推送实际上是将您的文件发送到远程存储库。