git bug或滥用分支?

时间:2009-09-14 02:10:10

标签: git branch

我有一个大型项目,我正在升级到边缘Rails。我制作了整个项目目录的副本,并在那里重构作为信任git的预防措施(或者至少我可能如何使用/滥用它)。在完成大部分工作后,我返回到原始项目目录和控制台(这是来自内存,因此基于实际发生的情况而松散):

git branch edge
git checkout edge
git rm vendor/plugins
git commit -m "wiped out old plugins"

然后我在我复制的项目中更新的插件的最新版本中手动复制。

git add vendor/plugins
git commit -m "re-added in plugins, some unchanged, some later versions"

我的理解是上面的添加是递归的。为了获得对git的一些信任,我在工作期间的不同时间在主分支和边缘分支之间来回交换,只是为了确保它正在处理交换正常。

git checkout master
git checkout edge

我注意到在边缘分支中(在一些交换之后),一些插件恢复为主版本。无数次我尝试提交有问题的插件的最新版本,但最终在交换后恢复。

我怀疑手动移动文件后添加文件的方式可能存在问题。 (git添加vendor / plugins / *是否必要?)当两个分支包含一些相同的子目录时,是否有人在分支之间交换有任何问题?您如何处理将在一个目录中找到的应用程序副本中找到的更改合并回原始文件?原始存储库是干净的,而副本相当混乱,因为试图让某些插件在边缘分支中保持更改。

2 个答案:

答案 0 :(得分:5)

这似乎是一种非常奇怪的方式来做你想要的事情。

做出你提出的建议的“git”方式更多:

$ git checkout -b edge
... #make your modifications for the port.
$ git commit -m'ported plugins to rails edge' -a
$ git checkout master # original code is there untouched
$ git checkout edge # ported code is there just as you commited it.

从那里取决于你的目标是什么:

$ git checkout master # make sure you are on the master branch
$ git merge edge # merge the edge branch into master
... # fix any errors
$ git branch -d edge # remove the edge branch since you don't need it anymore.

或维持两个分支。一个移到边缘,另一个移到边缘。这可能不是你想要的。 git中的分支既便宜又简单,完全可以把它们扔掉。

答案 1 :(得分:2)

git checkout不会删除不在提交中的文件。您必须使用git clean -f删除当前工作目录中的所有不需要的文件。你也可以再删除文件夹和git checkout -f

除此之外,最好创建一个分支来处理 edge 功能,然后将分支合并回来,就像jeremy wall所提到的那样