Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull specific commit code from bitbucket-git

I am using BitBucket-Git for my android application for version control. I have commited code five times.

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?

I just simply want to pull complete code till v3.

like image 881
N Sharma Avatar asked Jun 28 '14 17:06

N Sharma


People also ask

How do you git pull a specific commit?

How do I pull a specific commit? The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .


2 Answers

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.

If you want to continue committing from where v1 ended, use a hard reset:

$ git reset --hard v1
like image 149
Yuval Adam Avatar answered Oct 12 '22 06:10

Yuval Adam


I had the same query, this is how i solved it:

1.) Make a new branch in ur git directory:

git branch new-branch-name-here

2.) Switch into that branch

(git checkout new-branch-name-here)

3.) Once on that branch, type:

git reset commit-code-here --hard

(where commit-code-here is the commit name, in ur case v3.)

ull be back to that commit!

like image 33
TABISH KHAN Avatar answered Oct 12 '22 07:10

TABISH KHAN