简体   繁体   English

如何从特定提交中提取所有内容?

[英]How to pull everything from a specific commit?

在此处输入图像描述

I'm trying to pull everything from a specific commit im working with other people who have merged there branches that's why I want to pull from this commit how can I do that without messing up my own code?我试图从一个特定的提交中提取所有内容,我正在与其他合并了分支的人一起工作,这就是为什么我想从这个提交中提取我如何在不弄乱我自己的代码的情况下做到这一点? the specific commit is "merge 1" and is the highlighted one具体的提交是“合并1”并且是突出显示的

You can create a branch from any commit.您可以从任何提交创建一个分支。 So, knowing sha1 for your commit you can just所以,知道你的提交的 sha1 你可以

git branch mybranch a0fbc78

Now you have a named branch which points to your commit.现在你有一个指向你的提交的命名分支。 from now on you can do many things.从现在开始,你可以做很多事情。 You can check it out你可以检查一下

git checkout mybranch

you can create a worktree你可以创建一个工作树

git worktree add wtree-path mybranch

you can clone你可以克隆

git clone --single-branch --branch mybranch

you can pull it into another repo你可以把它拉到另一个仓库

git pull origin mybranch

These all things will not messup with your top of the tree code, assuming that you committed it before all those operations.假设您在所有这些操作之前提交了这些代码,所有这些都不会弄乱您的树代码顶部。

Try git fetch instead of git pull so that you can get the information from the remote without messing up with your current work.尝试git fetch而不是git pull以便您可以从远程获取信息而不会弄乱您当前的工作。

It seems, unfortunately, the only way is creating a new branch from the commit you want to pull and make the changes to the new branch.不幸的是,似乎唯一的方法是从您要提取的提交中创建一个新分支并对新分支进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM