Git Push会返回“一切都是最新的” [英] Git Push returns "Everything up-to-date"

查看:637
本文介绍了Git Push会返回“一切都是最新的”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将更新的文件推送到github上的远程存储库,使用git 1.8.4.2版运行OSX Snow Leopard。



我已成功完成 git init ,然后是 git add。 git remote add origin https://github.com/me/repo.git 。然后我做了一个 git commit -m第一次提交,后面跟着 git push origin master



所有这些工作都很好



问题是当我尝试提交并再次推送时,我有一条消息返回给我。例如,我更新了一些文件,做了一个提交消息,然后运行 git push remote origin



该命令的工作原理除了它说一切都是最新的。我扫描了大约六打左右的堆栈溢出问题,这些问题有相似的错误,其中很多问题涉及不在正确的分支或处于分离的头部模式。我相信我的情况都不是。



以下是 git log --graph --all --decorate --pretty = oneline

  * 6926001f0eed54c05f807eb04ed05fd0584cd2e6(HEAD,origin / master,master)first commit 

这里是 git remote show origin

  *远程原点
抓取网址:https://github.com/me/repo.git
推送网址:https:/ /github.com/me/repo.git
HEAD分支:master
远程分支:
跟踪的主数
为'git push'配置的本地ref:
主推掌握(最新)

这里是 git branch -v

  * master 6926001第一次提交

我不确定我可以提供哪些其他信息,但请让我知道,我会更新问题。



编辑:



我再次运行第二次提交,得到这样的消息:
$ b $ pre $ #在分支master上
#没有为commit提交更改:
#(使用git add< file> ...更新将要提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#modified:file1
#modified:file2
#modified:file3

没有更改添加到提交中(使用git add和/或git commit -a)


解决方案

您需要将文件添加到 git commit 之前的staging area实际上会进行一次新的提交。 1



暂存区可以让你按照你想要的方式来安排一切,有时候这与工作目录中的设置不同(例如,你可能需要调整配置文件来测试新功能的第1部分,但不能想要承诺
$ b 之前运行 git status 通常是明智的做法。 git commit 查看准备提交和尚未执行的内容。此外, git diff --cached 显示将提交的内容(比较 HEAD 提交到暂存区域),而 git diff 没有 - cached 显示了什么不会被提交,即什么作为捷径,你可以使用 git commit -a ,它会自动添加在 git status 中显示为修改已删除的文件。输出。 (但是这不会添加untracked文件,请再次参阅 git status 的输出。)



完整性,我将添加 git diff HEAD 显示如果您运行 git commit -a 则会提交的内容。 (这三个 git diff 变体列在 git diff documentation。)



以下是一些关于暂存区域的网络参考资料:

http://gitready.com/beginner/2009/01/18/the-staging-area.html



http://git-scm.com / book / en / Getting-Started-Git-Basics (这是Pro Git的书,非常好,但也可能会让人感到困惑,主要是因为git本身可能会让人困惑)

b
$ b

https://softwareengineering.stackexchange.com/questions/69178/what-i s-the-benefit-of-gits-two-stage-commit-process-stage






< sup> 1 技术上不太正确:更准确地说,就在提交之前, git commit 会快速比较它提交的内容与当前的 HEAD commit。如果没有区别,除非您指定了 - allow-empty ,否则它会停止。使用 -a ,提交内容包括修改和删除的文件;只有在没有的情况下,您仍然需要 - allow-empty 才能进行新的提交。


I am attempting to push my updated files to a remote repository on github, operating OSX Snow Leopard using git version 1.8.4.2.

I have successfully done git init followed by git add . and git remote add origin https://github.com/me/repo.git. I then did a git commit -m "first commit" followed by git push origin master

All of this worked great

The problem is that I have a message returned to me when I try to commit and push again. I updated some files for example, did a commit with a message, and then ran git push remote origin.

The command works except it says "Everything up-to-date". I scanned a half dozen or so stack overflow questions with similar errors and a lot of them relating to not being on the correct branch or being in detached head mode. I believe my case is neither.

Here is the result of git log --graph --all --decorate --pretty=oneline:

* 6926001f0eed54c05f807eb04ed05fd0584cd2e6 (HEAD, origin/master, master) first commit

and here is git remote show origin

* remote origin
  Fetch URL: https://github.com/me/repo.git
  Push  URL: https://github.com/me/repo.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

and here is git branch -v

* master 6926001 first commit

I am not sure what other information I can provide, but please do let me know and I will update the question. I am fairly new to git, thanks for reading!

Edit:

I ran the second commit again and got this message:

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   file1
#   modified:   file2
#   modified:   file3
#
no changes added to commit (use "git add" and/or "git commit -a")

解决方案

You need to add files to the "staging area" before git commit will actually make a new commit.1

The "staging area" lets you arrange everything the way you want it, which is sometimes not the same setup you need in the work directory (e.g., you might need to tweak a config file to test part 1 of a new feature, but not want to commit that particular config-file change yet).

It's generally wise to run git status before git commit to see what's ready to commit and what's not yet staged. Also, git diff --cached shows what will be committed (compares the HEAD commit to the staging area), while git diff without --cached shows what won't be committed, i.e., what is not yet staged.

As a short-cut, you can use git commit -a, which automatically adds files that show up as modified or deleted in git status output. (But this does not add "untracked" files. Again, see the output of git status.)

For completeness, I'll add that git diff HEAD shows what you would commit if you ran git commit -a. (These three git diff variants are listed in the git diff documentation, under the EXAMPLES section.)

Here are a few web references about the staging area:

http://gitready.com/beginner/2009/01/18/the-staging-area.html

http://git-scm.com/book/en/Getting-Started-Git-Basics (this is the Pro Git book, which is very good but can be quite confusing too, mostly because git itself can be pretty confusing).

https://softwareengineering.stackexchange.com/questions/69178/what-is-the-benefit-of-gits-two-stage-commit-process-staging


1Technically not quite true: more precisely, just before committing, git commit does a quick comparison of what it is to commit, vs the current HEAD commit. If there is no difference, it stops unless you've specified --allow-empty. With -a, "what it is to commit" includes modified and deleted files; only if there are none will you still need --allow-empty to make a new commit.

这篇关于Git Push会返回“一切都是最新的”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆