我一直在使用Windows上的Git (msysgit)来跟踪我一直在做的一些设计工作的更改。

今天我一直在一台不同的PC上工作(与远程repo brian),我现在正试图将今天完成的编辑合并到我笔记本电脑上的常规本地版本。

在我的笔记本电脑上,我已经使用git pull brian master将更改拉到我的本地版本。除了主InDesign文档之外,一切都很好-这显示为冲突。

PC (brian)上的版本是我想保留的最新版本,但我不知道什么命令告诉回购使用这一个。

我试图直接复制文件到我的笔记本电脑上,但这似乎打破了整个合并过程。

有人能告诉我正确的方向吗?


当前回答

我遇到过一个类似的问题(想要提交一个包含一些二进制文件的提交,这在合并时引起冲突),但遇到了一个不同的解决方案,完全可以使用git完成(即不必手动复制文件)。我想我应该把它包括在这里,这样至少我下次需要的时候可以记住它。:)步骤如下:

% git fetch

这将从远程存储库获取最新的提交(您可能需要指定一个远程分支名称,这取决于您的设置),但不会尝试合并它们。它在FETCH_HEAD中记录提交

% git checkout FETCH_HEAD stuff/to/update

这将获取我想要的二进制文件的副本,并使用从远程分支获取的版本覆盖工作树中的内容。Git不会尝试进行任何合并,因此您最终得到的只是来自远程分支的二进制文件的精确副本。完成之后,就可以像平常一样添加/提交新副本了。

其他回答

我遇到过在windows上使用Git管理二进制文件的差异/合并的两种策略。

Tortoise git lets you configure diff/merge tools for different file types based on their file extensions. See 2.35.4.3. Diff/Merge Advanced Settings http://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html. This strategy of course relys on suitable diff/merge tools being available. Using git attributes you can specify a tool/command to convert your binary file to text and then let your default diff/merge tool do it's thing. See http://git-scm.com/book/it/v2/Customizing-Git-Git-Attributes. The article even gives an example of using meta data to diff images.

我让这两种策略都适用于软件模型的二进制文件,但我们使用了tortoise git,因为配置很简单。

从git签出文档

git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... --ours --theirs When checking out paths from the index, check out stage #2 (ours) or #3 (theirs) for unmerged paths. The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the checkout operation will fail and nothing will be checked out. Using -f will ignore these unmerged entries. The contents from a specific side of the merge can be checked out of the index by using --ours or --theirs. With -m, changes made to the working tree file can be discarded to re-create the original conflicted merge result.

这个过程是在你向Github提交了一个pull请求后解决二进制文件冲突:

所以在Github上,你发现你的拉请求在二进制文件上有冲突。 现在回到本地计算机上相同的git分支。 您(a)再次重新制作/重新构建这个二进制文件,(b)将生成的二进制文件提交到相同的git分支。 然后你把这个相同的git分支再次推到Github。

在Github上,在你的拉请求时,冲突应该会消失。

我使用Git工作流的Excel - https://www.xltrail.com/blog/git-workflow-for-excel应用程序来解决我的二进制文件相关的合并问题。这个开源应用程序可以帮助我高效地解决问题,而不用花费太多时间,让我选择正确的文件版本而不会有任何困惑。

要解决这个问题,你需要将版本保存在当前分支中(忽略你正在合并的分支中的版本),只需添加并提交文件:

git commit -a

为了解决这个问题,你需要用你要合并的分支的版本来覆盖你当前分支中的版本,你需要首先检索那个版本到你的工作目录中,然后添加/提交它:

git checkout otherbranch theconflictedfile
git commit -a

详细解释