GIT如何使用不同的文件更新分支

时间:2021-04-17 19:56:54

I'm having a master branch with english texts and another branch called german_translation.

我有一个带有英文文本的主分支和另一个名为german_translation的分支。

The german branch is identical with the master branch - but the german branch has an additional folder /value-de with one file in it strings.xml.

德语分支与主分支相同 - 但德语分支有一个额外的文件夹/值-de,其中包含一个文件strings.xml。

When adding new stuff to the master branch, I want to update the german branch with the new stuff from master and add new translation text to the german strings.xml.

在向主分支添加新东西时,我想用master中的新东西更新德语分支,并将新的翻译文本添加到german strings.xml。

My problem is that a merge is not working because of that extra file and folder the german branch has.

我的问题是合并不起作用,因为德国分支有额外的文件和文件夹。

Is that a un/stash thing? However can you describe the full steps going throu this branch update process?

这是不是什么/藏匿的东西?但是,您能描述通过此分支更新过程的完整步骤吗?

Thanks in advance!

提前致谢!

EDIT: This is the error message I'm getting

编辑:这是我收到的错误消息

Can't merge because of unmerged files. You have to resolve all merge conflicts before merge. After resolving conflicts you also probably would want to commit your files to the current branch.

由于未合并的文件无法合并。您必须在合并之前解决所有合并冲突。解决冲突后,您可能还希望将文件提交到当前分支。

EDIT2: (that's german ...)

编辑2 :(这是德国......)

git status

# Auf Branch german_translation
# Sie haben nicht zusammengeführte Pfade.
#  (beheben Sie die Konflikte und führen Sie "git commit" aus)
#
# zum Commit vorgemerkte Änderungen:
#
#       geändert:   src/main/res/values/strings.xml
#
# Nicht zusammengeführte Pfade:
#   (benutzen Sie "git add/rm <Datei>..." um die Auflösung entsprechend zu markieren)
#
#       von denen gelöscht: src/main/res/values-de/strings.xml
#

1 个解决方案

#1


1  

One possibility is that the file values-de/strings.xml was at one point present on the master branch, and subsequently deleted. In the meantime, on the german translation branch, the same file had updates not present on the master branch.

一种可能性是文件值-de / strings.xml在主分支上存在一个点,随后被删除。与此同时,在德语翻译分支上,同一文件的主分支上没有更新。

When the next merge from master occurred, it included the delete operation for the values-de/strings.xml, but since there are updates on the branch, it couldn't be completed, instead resulting in a merge conflict.

当发生下一次来自master的合并时,它包含了values-de / strings.xml的删除操作,但由于分支上有更新,因此无法完成,而是导致合并冲突。

Right now git is asking you to resolve this merge conflict manually, i.e., which takes precedence, the deletion of the file, or the changes made to it on this branch?

现在git要求你手动解决这个合并冲突,即优先,删除文件,或者在这个分支上对它做出的改变?

If you want to keep the file with the changes, then execute

如果要保留文件中的更改,请执行

git add src/main/res/values-de/strings.xml
git commit

if not, you would execute:

如果没有,你会执行:

git rm src/main/res/values-de/strings.xml
git commit

This would complete your last merge, so now you can merge again to get the latest.

这将完成您的上次合并,所以现在您可以再次合并以获取最新的。

Also, you may want to consider keeping your german translation in the master branch. Branches are generally for keeping past versions or for feature development.

此外,您可能需要考虑将德语翻译保留在主分支中。分支通常用于保留过去的版本或用于功能开发。

#1


1  

One possibility is that the file values-de/strings.xml was at one point present on the master branch, and subsequently deleted. In the meantime, on the german translation branch, the same file had updates not present on the master branch.

一种可能性是文件值-de / strings.xml在主分支上存在一个点,随后被删除。与此同时,在德语翻译分支上,同一文件的主分支上没有更新。

When the next merge from master occurred, it included the delete operation for the values-de/strings.xml, but since there are updates on the branch, it couldn't be completed, instead resulting in a merge conflict.

当发生下一次来自master的合并时,它包含了values-de / strings.xml的删除操作,但由于分支上有更新,因此无法完成,而是导致合并冲突。

Right now git is asking you to resolve this merge conflict manually, i.e., which takes precedence, the deletion of the file, or the changes made to it on this branch?

现在git要求你手动解决这个合并冲突,即优先,删除文件,或者在这个分支上对它做出的改变?

If you want to keep the file with the changes, then execute

如果要保留文件中的更改,请执行

git add src/main/res/values-de/strings.xml
git commit

if not, you would execute:

如果没有,你会执行:

git rm src/main/res/values-de/strings.xml
git commit

This would complete your last merge, so now you can merge again to get the latest.

这将完成您的上次合并,所以现在您可以再次合并以获取最新的。

Also, you may want to consider keeping your german translation in the master branch. Branches are generally for keeping past versions or for feature development.

此外,您可能需要考虑将德语翻译保留在主分支中。分支通常用于保留过去的版本或用于功能开发。