You can't just download a particular commit. Instead of you can clone a specific branch from the remote repository and then switch to any commit.
Here is the syntax of the command to clone the specific git branch.
git clone -b <BRANCH_NAME> <GIT_REMOTE_URL>
You can use --single-branch
to prevent fetching details of other branches like below:
git clone -b <BRANCH_NAME> --single-branch <GIT_REMOTE_URL>
If you go to the directory of your downloaded project and run the following command:
git branch -a
you can see the .git
folder does not include information about other branches.
So now, fetch your desired commit by the following command:
git checkout <COMMIT_SHA1_KEY>
Note: You can clone only the latest commit from a given branch by using --depth=n
git clone -b <BRANCH_NAME> --single-branch --depth=2 <GIT_REMOTE_URL>