git - 不在 GIT 中的第三方项目 - 新版本 - 保留我的更改

标签 git conflict

我从 Codecanyon 购买(许可)了一些不在 GIT 中维护的代码。 我现在对它做了很多更改(使用 GIT)。 很快原始代码的作者将发布一个新版本。 我会想在不丢失我自己的情况下 merge 他们的更改。 因此,我想加载他们的代码并让 GIT 指出冲突,以便我可以(希望)将新代码 merge 到我的代码中。 谁能推荐一种安全的方法来实现这一目标? 谢谢。

最佳答案

如果您在本地存储库中提交了他们代码的第一个版本:

$ git log --graph --oneline
1234ee * (HEAD -> master) my latest changes 
1234dd * added a feature
  ...
1234aa * a commit, with the initial version of the product's code
  ...

你可以:

  • 创建一个从该提交开始的分支:
git checkout -b upstream 1234aa
  • 用新版本更新代码:
# to be thorough : you should delete files which existed in the first version,
# and do not exist in the new version
git rm -- [list all files of original archive]

# for example, here is one way to drop all versioned files :
git rm -- "*"

# extract the files from the new version :
tar -xzf newversion.tgz

# add and commit :
git add .
git commit -m "new version"
  • 您现在可以在本地分支中 merge upstream :
git checkout master
git merge upstream

关于git - 不在 GIT 中的第三方项目 - 新版本 - 保留我的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67079091/

相关文章:

Git - 如何在所选文件上强制 merge 冲突和手动 merge

git - 使浅层 GIT 存储库不那么浅

git - 如何 git cherry-pick 使用二进制文件提交

git - 最新版Git-安装时没有SSH选项

windows - Hudson git 命令*慢得令人难以置信*

git commit config 在初始提交但再也没有提交?

c++ - 如何包含同一 header 的两个不同版本?

jquery - 如何让 Iscroll 和 Lazy Load jQuery 插件一起工作?

git - 如何解决 Webmatrix 3 中的 GIT 冲突?

git - 当 Dan 将文本更改为 'aB' 并将 John 更改为 'abc' 时会发生什么?