The answer to similar questions on SO seems to always be "merge/pull before pushing" or "don't get into the situation in the first place". Neither of those apply.
关于SO的类似问题的答案似乎总是“在推动之前合并/拉动”或“首先不进入这种情况”。这些都不适用。
I've inherited maintenance of a website in which ongoing development has branched from maintenance of the old site. However, I've discovered that legacy fixes weren't always made local->git->test->live. Sometimes they were test->live, skipping git, and sometimes they were made directly to Live.
我继承了一个网站的维护,其中正在进行的开发已经从旧网站的维护中分支出来。但是,我发现遗留修复并不总是本地 - > git-> test-> live。有时他们是测试 - >现场,跳过git,有时他们直接进入Live。
Thus, the Live environment does not exactly match any git commit nor the test server nor my local environment. This is a problem.
因此,Live环境与任何git提交,测试服务器和本地环境都不完全匹配。这是个问题。
I created a new branch for how live currently is, but when I tried to push, git refused -- claiming changes had been made to the central repository, and "non-fast-forward updates were rejected".
我为当前的生活创建了一个新分支,但是当我尝试推送时,git拒绝了 - 声称对*存储库进行了更改,并且“非快进更新被拒绝”。
I don't want to merge into the live server. I think the unmerged changes are developmental (proper branch management wasn't always fastidiously followed), but even if there are fixes in the central that should be live, the live server is not the place to perform that merge.
我不想合并到实时服务器。我认为未合并的更改是开发性的(正确的分支管理并不总是被严格遵循),但即使*应该有实时修复,实时服务器也不是执行合并的地方。
The answer seems to be a "git push --force" from live, and deal with merges and general git cleanup on the local.
答案似乎是来自现场的“git push -force”,并处理合并和本地的一般git清理。
But I haven't used --force before, and from my searching for an answer, it seems to sometimes work differently than what people expect.
但我之前没有使用过--force,而且在我寻找答案时,它似乎有时与人们的期望不同。
So, I need a sanity-check. will:
所以,我需要一个完整性检查。将:
git checkout -b new_branch_name
git add -u
git add *
git commit -m "new branch to match how live is currently"
git push --force
push my new branch to the central repository exactly how it is on the server from which I'm running the commands, without affecting any other branches?
将我的新分支机构推送到*存储库的确切方式是在我运行命令的服务器上,而不影响任何其他分支机构?
Contrarily, is there a better method to deal with getting the git repositories cleaned up, and a testing environment that matches live?
相反,有没有更好的方法来处理清理git存储库,以及匹配实时的测试环境?
Since this is the live server, I can't just-try-it-and-see-if-it-works.
由于这是实时服务器,我不能只是尝试它看看它是否正常工作。
1 个解决方案
#1
1
Here's what I ended up doing:
这是我最终做的事情:
Just to avoid trying out how-I-think-git-works-but-I-haven't-actually-done-this-trick-previously on a live site, I created a NEW local repo from the current contents of the live server. From here, I can get fancy -- on my LOCAL drive -- with comparing and moving branches between repos, until I have this mess cleaned up.
为了避免尝试如何 - 我认为-git-works-but-I-yet-actual-done-trick-trick-before-live site,我在现场的当前内容中创建了一个新的本地回购服务器。从这里开始,我可以看到 - 在我的本地驱动器上 - 在回购之间比较和移动分支,直到我清理了这个混乱。
Holding off on accepting my answer, in case someone with more knowledge posts a better one.
不要接受我的回答,以防有更多知识的人发布更好的答案。
#1
1
Here's what I ended up doing:
这是我最终做的事情:
Just to avoid trying out how-I-think-git-works-but-I-haven't-actually-done-this-trick-previously on a live site, I created a NEW local repo from the current contents of the live server. From here, I can get fancy -- on my LOCAL drive -- with comparing and moving branches between repos, until I have this mess cleaned up.
为了避免尝试如何 - 我认为-git-works-but-I-yet-actual-done-trick-trick-before-live site,我在现场的当前内容中创建了一个新的本地回购服务器。从这里开始,我可以看到 - 在我的本地驱动器上 - 在回购之间比较和移动分支,直到我清理了这个混乱。
Holding off on accepting my answer, in case someone with more knowledge posts a better one.
不要接受我的回答,以防有更多知识的人发布更好的答案。