[英]Unified updates : Update private repo with updates from local files(refactored, renamed, updated) & get regular updates from original repo
我刚刚开始在 Windows 上向我们学习 GitHub CLI 工具。考虑我是一个新手,我有一个如下所示的用例:
在我go稍微深一点之前总结一下:
我的用例是:克隆一个开源项目(定期更新),即创建它的本地副本并进行修改(包括重命名文件和文件夹),将更改推送到我的私人仓库,但同时我需要定期更新来自以重命名格式反映的开源项目。 每次项目发布更新并将其推送到我的私人仓库时,我是否必须重命名文件和文件夹?
假设项目 A 是一个定期更新其文件的开源项目。 项目 B 是我在 GitHub 上的私人仓库。将我的项目 C(本地仓库)链接到 Origin(项目 B)和上游(项目 A)的所有初始步骤都已通过 .git 文件夹中的 cli 和配置文件完成。
在我的电脑上,我的本地副本Project C已经通过命令获取
git 克隆“https:..../project-B.git”
现在我的目的如下:
1.对我计算机上本地副本项目 C 中的代码本身进行大量自定义,并将这些更改推送到我的私人副本:项目 B。这包括但不限于重命名项目文件夹和文件。
2.从项目A获取定期更新,同样需要在私有仓库项目B中更新。
简而言之,我的私人回购项目 B 应该有我的更改以及从上游端发生的常规更改:项目 A
实现这一目标的最佳方法是什么? 我知道将我的本地副本推送到私人回购 B 的以下步骤:
Step 1 : git status -->to check for the changes in local copy.
Step 2 : git add --all
Step 3 : git commit -m 'message reflecting the nature of change'
Step 4 : git push -u origin master
where origin is my Private repo B and master is the branch that contains all the files.
我也知道通过使用以下方式提取上游文件:
git pull upstream master --> to pull in the latest changes from project A onto project B.
因此,我的问题是:
1.我究竟应该在什么时候使用 git pull 或 git rebase with find renames:在我推送提交的更改之前或之后。 我有限的理解是 git rebase 是在原始文件中找到重命名的文件(在我的用例中)并进行更改?
或者
2.我需要一种完全不同的方法吗?
或者
3.对上述内容进行微小改动的方法?
编辑:
我已经使用命令 git push -u origin master 成功推送了我的本地更改(项目 C-> 项目 B(git 上的私有仓库)。
只是,我需要知道如何从 repo 项目 A(定期更新的开源)中提取更改并更新我当前已重命名的本地副本(文件夹,文件其他所有内容)和其他添加的新代码行。 最终我需要从项目 C(本地副本)---> 项目 B(私人回购)推送这些更新的更改,并让我的私人回购 UpToDate 最新提交。
编辑:将公共回购 docker-jitsi-meet 作为回购,我需要定期更新,并在我的私人回购中进行修改和重命名。 我做了以下事情:
1.我将公共 jitsi-meet 仓库克隆到我的本地机器上。
2.git 克隆 --bare github.com/jitsi/docker-jitsi-meet.git。
3.cd 到我的本地副本和 git 推送 github.com/user/project.git(私人回购)。
4 删除裸副本并立即克隆回购 git 克隆 github.com/user/project.git
5.将公共上游仓库添加为远程:git 远程添加上游 github.com/jitsi/docker-jitsi-meet.git。
6 git fetch --all 向我展示了我需要引入的来自上游的大量更改。
git 合并 upstream/master 并显示以下跟踪:
$ git merge upstream/master
Auto-merging CHANGELOG.md
Auto-merging docker-compose.yml
CONFLICT (content): Merge conflict in docker-compose.yml
Auto-merging focus/rootfs/defaults/jicofo.conf
CONFLICT (content): Merge conflict in focus/rootfs/defaults/jicofo.conf
CONFLICT (modify/delete): jibri/Dockerfile deleted in HEAD and modified in upstream/master. Version upstream/master of jibri/Dockerfile left in tree.
CONFLICT (modify/delete): prosody/rootfs/etc/cont-init.d/10-config deleted in HEAD and modified in upstream/master. Version upstream/master of prosody/rootfs/etc/cont-init.d/10-config left in tree.
Auto-merging web/rootfs/defaults/system-config.js
CONFLICT (content): Merge conflict in web/rootfs/defaults/system-config.js
Auto-merging xmpp/rootfs/defaults/conf.d/jitsi-meet.cfg.lua
CONFLICT (content): Merge conflict in xmpp/rootfs/defaults/conf.d/jitsi-meet.cfg.lua
Automatic merge failed; fix conflicts and then commit the result.
git $ git 合并上游/master -X --strategy-option="find-renames=20"
并得到以下内容:
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
最简单的方法通常是在本地克隆中添加两个遥控器,然后不断合并来自辅助遥控器的更改。 遥控器就像另一个存储库的书签; 当您克隆时,会自动为您创建origin
遥控器,它指向您克隆的来源。
以下命令只需执行一次:
git clone https://github.com/user/project.git localclone
cd localclone
git remote add upstream https://github.com/upstream/project.git
然后稍后“同步”你的叉子:
git fetch --all
git merge upstream/master
git push origin HEAD
这将合并自上次获取+合并以来“上游”远程/存储库的“主”分支中发生的所有更改。
请注意,如果上游中的提交更改了与您在分叉中所做的相同的行,则会出现您需要解决的合并冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.