gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 15:00:13 28 4
gpt4 key购买 nike

我从 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com