"Clone git Repository on Storage Server" question

So this question has a repository on the storage server at /opt/somerepo.git, and you are asked to clone this to another directory such as /usr/src/kodekloud/.

Initially I did a "sudo git clone /opt/somerepo.git /usr/src/kodekloud/. I could see the cloned repo but the system was saying that the answer was wrong.

Then I happened to see a “Review task” about the same question, and did the following:
cd into the destination dir, and sudo git clone /opt/somerepo.git.
This worked.

So my question is, why? Was my method really wrong or did the system expect me to specifically cd into the destination dir and do a git clone?

Hi @DanF

The two commands you provided perform similar tasks, but there are key differences in how they handle the destination of the cloned repository.

Did you see a .git hidden-directory when you list files in /usr/src/kodekloud/somerepo?

Regards

HI @Santosh_KodeKloud,

Thanks for the reply. Yes the hidden .git dir was there. The only difference I could see is that it didn’t copy the git with its full name. So if it was code.git, now I only had .git in the destination dir.

In any case, could you or someone explain the key differences between the two methods? :slight_smile: Although my impression is that in the real world you are more likely to clone repos via SSH rather than using this method? Correct me if wrong.

Regards.

yep, I’m also wondering why we need to clone the repository with the name like ‘sample_repo.git’ rather ‘.git’ directory itself. In real world scenario, what would be the best practice and why?