git 基于SHA的git pull
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11990090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git pull based on SHA
提问by d3bug3r
I would like to know how to do a pull from repo based on a SHA?
我想知道如何根据 SHA 从 repo 中提取?
git pull origin master
the above code will pull master once we've done git add remote
.
一旦我们完成,上面的代码将拉取主人git add remote
。
回答by Eric
A git pull does two things for you:
git pull 为你做两件事:
- Fetches a specific branch from the repository
- Merges it with your current branch.
- 从存储库中获取特定分支
- 将它与您当前的分支合并。
It sounds like what you want to do is to get a specific revision from the repository and merge it with your current branch.
听起来您想要做的是从存储库中获取特定修订并将其与当前分支合并。
The best way to do this is two commands:
执行此操作的最佳方法是两个命令:
git fetch origin
git merge YOUR_SHA_HERE
If what you want is just to see what's in a specific revision from the repository and make it the working tree, but not do a merge, then you would want:
如果您只想查看存储库中特定修订版中的内容并将其设为工作树,而不是进行合并,那么您可能需要:
git fetch origin
git checkout YOUR_SHA_HERE
If what you want is to get the specific version, and make it the new "master" (or another branch), then you would want to run
如果您想要的是获取特定版本,并使其成为新的“主”(或另一个分支),那么您需要运行
git fetch origin
git reset --hard YOUR_SHA_HERE
All of these will fetch new code from the repository (via the 'git fetch origin'), but then there are different ways to combine with / replace your current code.
所有这些都将从存储库中获取新代码(通过 'git fetch origin'),但是有不同的方法可以结合/替换您当前的代码。
回答by wadesworld
I don't think there's a way to pull just part of a branch based on a SHA.
我认为没有办法根据 SHA 只提取分支的一部分。
What's wrong with:
有什么问题:
git pull
git reset --hard <sha>