gpt4 book ai didi

Git 推送返回 "Everything up-to-date"

转载 作者:太空狗 更新时间:2023-10-29 13:55:53 28 4
gpt4 key购买 nike

我正在尝试将我的更新文件推送到 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 "first commit" 然后是 git push origin master

所有这些都很好用

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

除了显示“Everything up-to-date”之外,该命令有效。我扫描了大约六个具有类似错误的堆栈溢出问题,其中很多与不在正确的分支上或处于分离头模式有关。我相信我的情况两者都不是。

这是 git log --graph --all --decorate --pretty=oneline 的结果:

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

这里是 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)

这里是 git branch -v

* master 6926001 first commit

我不确定我还能提供哪些其他信息,但请告诉我,我会更新问题。我是 git 的新手,感谢阅读!

编辑:

我再次运行第二次提交并收到此消息:

# 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")

最佳答案

git commit 实际进行新提交之前,您需要将文件添加到“暂存区”。1

“暂存区”让您可以按照自己的方式安排所有内容,这有时与您在工作目录中需要的设置不同(例如,您可能需要调整配置文件以测试新功能的第 1 部分,但还不想提交特定的配置文件更改)。

通常明智的做法是在 git commit 之前运行 git status 以查看哪些内容已准备好提交,哪些内容尚未暂存。此外,git diff --cached 显示将提交的内容(比较 HEAD 提交到暂存区),而 git diff 没有 --cached 显示不会提交的内容,即尚未上演的内容。

作为快捷方式,您可以使用 git commit -a,它会自动添加显示为 modifieddeleted 的文件git status 输出。 (但这不会添加“未跟踪”文件。再次查看 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 本身也很让人困惑)。

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


1技术上不太正确:更准确地说,就在提交之前,git commit 快速比较要提交的内容与当前的 HEAD 提交。如果没有区别,它将停止,除非您指定了 --allow-empty。使用-a,“要提交的内容”包括修改和删除的文件;仅当没有时,您仍然需要 --allow-empty 来进行新的提交。

关于Git 推送返回 "Everything up-to-date",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23921293/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com