我如何在不是工作室而是从同一遥控器克隆的本地存储库之间的提交?

发布于 2025-01-25 21:11:37 字数 124 浏览 1 评论 0原文

我厌倦了在分支之间切换。因此,我在PC上将存储库克隆了两次。

现在,我有两个不同的回购文件夹。

我想将我对较旧克隆的特定本地提交复制到较新的克隆。哪一套git命令可以帮助我做到这一点? (也许是樱桃挑吗?)

I'm tired of switching between branches. So, I cloned the repo twice on my PC.

Now, I have two different folders of the same repo.

I want to copy a specific local commit that I have on the older clone to the newer clone. Which set of git commands can help me to do it? (cherry-pick maybe?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2025-02-01 21:11:37

长期,您想要的是使用GIT工作室。

为了修复您当前的情况,您可以通过从本地目录创建遥控器来挑选回购之间的挑选。

通过将另一个本地存储库作为遥控器添加并进行git提取,您可以将您想要的任何提交挑选出您想要的任何提交。

例如,如果您想从old_clone中挑选以e9bee1bc开始的sha consit:

cd /projects/new_clone
git remote add old_clone /projects/old_clone
git fetch old_clone
git cherry-pick e9bee1bc

您也可以使用类似的策略将多个克隆的远程转换为工作者。例如,如果您想从原始项目创建一个工作室,并从branch1 new_clone添加本地副本到新的Worktree:

cd /projects/original
git worktree add /projects/worktree_1
cd /projects/worktree_1
git remote add new_clone /projects/new_clone
git fetch new_clone
git switch -c branch1 new_clone/branch1

Long term, what you want is to use git worktrees.

In order to repair your current situation, you can cherry-pick between repos by creating remotes from your local directories.

By adding another local repo as a remote and doing a git fetch, you can cherry-pick any commit you want from that repo with just the SHA.

For example, if you want to cherry-pick the commit from old_clone with a SHA starting with e9bee1bc:

cd /projects/new_clone
git remote add old_clone /projects/old_clone
git fetch old_clone
git cherry-pick e9bee1bc

You could also use a similar strategy to convert your multiple cloned remotes into worktrees. For example, if you want to create a worktree from your original project and add a local copy of branch1 from new_clone to your new worktree:

cd /projects/original
git worktree add /projects/worktree_1
cd /projects/worktree_1
git remote add new_clone /projects/new_clone
git fetch new_clone
git switch -c branch1 new_clone/branch1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文