【发布时间】:2023-04-06 11:22:01
【问题描述】:
我一直在堆栈和其他论坛上搜索并尝试各种解决方案,但似乎无法解决此问题。
Git: Branch is ahead by X commits. Doesn't help doing git pull
Why does git say I am 40 commits ahead when I seem up to date and a push-pull (no files) fixes it?
总体问题是,我拉了一个站点结帐,然后不得不对配置(数据库、api 位置等)进行一些本地更改,并防止每次我继续执行并提交时都必须存储和重新应用这些文件的本地更改。我在 1 个本地提交下完成了所有这些作为“本地配置提交”。而此时 git status 显示其领先 1。
root@web1 web]# git status
On branch master
Your branch is ahead of 'origin/master' by 1 commits.
但是,在过去的一个月里,我们一直在开发和修复一些东西。我们都从我们单独的分支中工作,然后合并回一个开发分支,然后从那里到 master 等等。一切准备就绪后,我进入生产环境并使用“git pull”拉下更改。这似乎一直运作良好,但是我今天注意到状态现在已经改变了。
root@web1 web]# git status
On branch master
Your branch is ahead of 'origin/master' by 31 commits.
当我查看针对 origin/master 的 git 日志时,似乎我看到了作为本地提交的合并?
小日志sn-p:
[root@web1 web]# git log origin/master..HEAD
commit 336743eb411804487ad2f8a2e31701b094fb03f0
Merge: 58c8230 3478924
Author: root <root@web1.(none)>
Date: Fri Feb 1 15:32:35 2013 -0500
Merge branch 'master' of http://gitrepo.com/Site
commit 58c82303c523a3c9217dd677ba23582e168007cc
Merge: 6c9de32 0e1c327
Author: root <root@web1.(none)>
Date: Fri Feb 1 15:04:58 2013 -0500
Merge branch 'master' of http://gitrepo.com/Site
commit 6c9de32c2fed77e442e73389aa8041f067a23cc4
Merge: ff586b4 52a7ea9
Author: root <root@web1.(none)>
Date: Fri Feb 1 14:38:08 2013 -0500
Merge branch 'master' of http://gitrepo.com/Site
我怀疑我的 repo 已经被正确地“快进”了,并且在每次拉取后仍然提前 1 次提交。在对 origin/master 进行比较时,您可以看到我没有太多更改(似乎)只是配置。这是来自原始配置更改和本地提交。
[root@web1 web]# git diff origin/master..HEAD --name-only
application/config/api.php
application/config/config.php
application/config/database.php
我尝试了上面的各种链接,并尝试了获取、更多拉取等,但无济于事。有没有一种方法可以让我的本地仓库正确地快进,这样我只能看到我所做的 1 个本地提交是我的 var 'ahead'?我不能完全将这些更改推送到 master,因为这会导致这些更改被拉到其他安装。然后我想在解决这个问题之后,最好的部署方式是什么,更改一些配置并能够不断更新。根据我的理解 stash 会起作用,但这实质上会使您的更改不合适,然后您可以拉动,然后重新申请,但我无法承受这个小步骤的停机时间,特别是如果它涉及必须整理任何合并冲突。
或者,有没有一种方法可以让我从提交中提取这些文件,以便我可以推送以对所有内容进行排序?
【问题讨论】:
标签: git git-commit fast-forward