Git -- cloning a previous commit in a different folder than local working directory
You are confusing clones/repositories and commits. Your command
git clone url_path_to_myprojects_repository
Is only missing one step:
git checkout ghijkl
This will get you the older commit. git clone
accepts URLs to a repository and downloads the complete history of the repository and checks out the latest commit of the default branch by default. git checkout
usually expects a commit and will make your working tree on disk match the given commit from your local repository. The newer switch
subcommand does the same.
That said, if you are not interested in the history at all, you can easily create an archive from any tree-ish (e.g. a commit):
cd url_path_to_myprojects_repository
git archive -o source.tar ghijkl
Or possibly even, depending on your remote repository configuration:
git archive -o source.tar --remote=url_of_origin_repository ghijkl
Later, you can extract the archive in any directory you wish. It is also possible to immediately extract the archive, without writing the file to disk:
git archive ghijkl | tar -xC temp_outside_source_control