如何从 bitbucket-git 中提取特定的提交代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24469527/
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
How to pull specific commit code from bitbucket-git
提问by N Sharma
I am using BitBucket-Git for my android application for version control. I have commited code five times.
我正在将 BitBucket-Git 用于我的 android 应用程序进行版本控制。我已经提交了五次代码。
Suppose I have done five commits v1, v2, v3, v4, v5. Now I want to get the complete source code till I have v3 commit only. Is there any way to get that?
假设我已经完成了五次提交 v1、v2、v3、v4、v5。现在我想获得完整的源代码,直到我只有 v3 提交。有没有办法得到它?
I just simply want to pull complete code till v3.
我只是想把完整的代码拉到 v3。
回答by Yuval Adam
You can't pull a single commit. Rather, clone the repository and checkout the commit you are interested in:
你不能拉一个提交。相反,克隆存储库并签出您感兴趣的提交:
$ git clone <repo>
$ git checkout v1
This will create a detached HEAD
state in your working copy, mirroring the state in commit v1
.
这将HEAD
在您的工作副本中创建一个分离状态,镜像 commit 中的状态v1
。
If you want to continue committing from where v1
ended, use a hard reset:
如果您想从v1
结束的地方继续提交,请使用硬重置:
$ git reset --hard v1
回答by SUPER USER
I had the same query, this is how i solved it:
我有同样的疑问,这就是我解决它的方法:
1.) Make a new branch in ur git directory:
1.) 在你的 git 目录中创建一个新分支:
git branch new-branch-name-here
2.) Switch into that branch
2.) 切换到那个分支
(git checkout new-branch-name-here)
3.) Once on that branch, type:
3.) 在那个分支上,输入:
git reset commit-code-here --hard
(where commit-code-here is the commit name, in ur case v3.)
(其中 commit-code-here 是提交名称,在您的情况下为 v3。)
ull be back to that commit!
你会回到那个提交!