我有一个Java项目,现在我将它更改为使用Gradle,并且必须更改整个项目结构。为此,我创建了一个全新的Java项目,并复制粘贴了代码文件。正如我所期待的那样,我不能仅仅把这个项目合并到Github上的主分支。有什么办法可以覆盖旧的支部吗?我不需要旧的结构,代码是一样的。我也不想在不同的文件夹上重复代码。我怎么才能解决这个问题?
摘要
我想用新代码覆盖旧代码,因为这是一个复杂的多项目解决方案,包含共享代码和多平台,如果我只保留新代码并丢弃旧代码,那么许多冲突就会更容易解决。
发布于 2016-02-10 16:44:43
这是我的建议-
或者-
1) Just make the changes in new master
2) Push it as a new branch
3) Use it as the origin for your future forks.
您可以不推荐老主人,这样您也可以拥有更改的历史记录,唯一会更改的是您的原始URI。
重新命名你的分支-
git branch -m old_branch new_branch
git push origin new_branch
发布于 2016-02-10 16:41:04
因此,假设您在本地存储库中将旧的主服务器作为master
分支,而新的主分支为new-master
。您希望将new-master
中的更改合并到master
中,并在发生冲突时始终接受new-master
引入的更改。要执行此操作,请执行以下操作:
git checkout master
git merge -X theirs new-master
之后,master
将包含在new-master
中所做的所有更改。现在,您可以简单地将master
分支推到github。您不会丢失任何版本历史记录。
-X theirs
的git-合并手册页描述。
ours
This option forces conflicting hunks to be auto-resolved cleanly by
favoring our version. Changes from the other tree that do not conflict
with our side are reflected to the merge result. For a binary file,
the entire contents are taken from our side.
This should not be confused with the ours merge strategy, which does
not even look at what the other tree contains at all. It discards
everything the other tree did, declaring our history contains all
that happened in it.
theirs
This is the opposite of ours.
如果要删除历史记录并重新开始使用新的存储库,则需要强制将新的本地存储库推送到github存储库。
git push --force origin master
另请参阅:
在执行该命令之前,请务必了解您正在做什么。强制推送到公共存储库通常是个坏主意。特别是,如果你不是唯一的开发人员。
https://stackoverflow.com/questions/35320849
复制相似问题