Reputation: 7966
I have a git repository cloned from GitHub. I want to study and test the written code at each commit, to track the behavior of the code. Are there any way to extract code until some commit to new repository to facilitate the study process
Upvotes: 4
Views: 125
Reputation: 5475
Edit:
I think I misread your question.
To fetch a specific commit into your repository you can do
git log
That shows you a list of commits with its hashes. Then you can take one hash and replace #HASH in the next line
git checkout #HASH
This will leave you with a detached state (not committable) but with a specific commit checked out.
To get back to the latest version (and an attached state) use:
git checkout master (or another branch name)
Original Answer:
You want that project to be a git submodule of your project.
This command clones a (remote) git repository into your git repo as submodule:
git submodule add <repository> [<path>]
You will have to manually pull (in the dir of the submodule) every time you want to update the remote project.
For more information on submodules see: https://git-scm.com/docs/git-submodule
Edit 2:
You can combine these two things (submodule with a specific commit checked out)
Upvotes: 2