I am new to git.
I have accidentally removed part of the history for our project on git. Now, I want to set the head to the latest stable release. The issue is the tree to which i want to set the HEAD to is not accessible from it commands, but i can access it through browser.
Does anybody know how to clone a specific tree using its SHA?
I have tried git reset SHA, but the SHA is not recognized.
I have also tried git clone -b SHA repo.git
, but it did not work either.
You mix up different concepts.
Whenever you clone, you clone a whole repository. (There is no way to clone a specific "tree".)
A repository mainly consist of many commits. Those are the ones you can checkout. Each commit knows its parent commit - this forms a history tree.
A commit itself contains a directory tree with all the files.
Usually there is some kind of server hosting the "central" repository.
You first clone your repository. This will create a complete copy of that central repository on your host. (With all the branches and commits.)
Afterwards you usually only interact with your local repository.
From you error message (unfortunately hidden only in some comment) it seems like your projects might use submodules. (A way of including a completely different repository in your project.)
This tends to be a bit tricky. Have a look at http://git-scm.com/book/en/Git-Tools-Submodules.
Has this "latest stable release" already pushed to the server? If yes, you can run a git fetch
and git checkout SHA
.
If this particular commit is only in your local history, do a git reflog
and identify the commit. Then checkout the desired commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With