Answer the question
In order to leave comments, you need to log in
Is it possible to clone a git repository by sha1 (commit hash)?
In the project, we build builds through Hudson.
To get the code, we do git clone
I want to build builds for a specific branch and commit.
The problem is that everything works fine for the branch name, i.e.:
git clone our_repo/repo_name.git -b master_Branch_Name
But if we put a hash instead of the branch name, say:
git clone our_repo/repo_name.git -b c0ff7a5663a73790746a084b023c3f75ec6b0465
We get fatal: Remote branch c0ff7a5663a73790746a084b023c3f75ec6b0465 not found in upstream origin
Yes, you can first
git clone our_repo/repo_name.git
...
git checkout
c0ff7a5663a73790746a084b023c3f75ec6b0465
Or why doesn't git clone -b work?
Answer the question
In order to leave comments, you need to log in
Looks like I found something. You can't do this for security reasons.
Read more here:
git.661346.n2.nabble.com/Fetch-by-SHA-missing-td56...
and here:
thread.gmane.org/gmane.comp.version-control.git/73...
I would advise using tags in this case, it will make life easier for everyone:
git tag -a v0.0.7 -m "Tagged version 0.0.7"
git push --follow-tags
because
-b
Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository's HEAD, point to branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.
Use tags, and in general, what's wrong with 2 lines?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question