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?
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? 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.
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?
I have tried two ways and I am seeing incorrect answer for 2 approaches, Pls check and suggest/help to resolve this issue.
Git - Task#2: Clone Git Repository on Storage Server
The DevOps team established a new Git repository last week, which remains unused at present. However, the Nautilus application development team now requires a copy of this repository on the Storage Server in the Stratos DC. Follow the provided details to clone the repository:
a. The repository to be cloned is located at /opt/beta.git
b. Clone this Git repository to the /usr/src/kodekloudrepos directory. Ensure no modifications are made to the repository during the cloning process.
Solution
$ ssh natasha@ststor01
$ git --version
git version 2.43.0
Approach-1
$ cd /usr/src/kodekloudrepos
$ sudo git clone /opt/beta.git
Approach-2
$ cd /usr/src/kodekloudrepos
$ sudo git clone /opt/beta.git /usr/src/kodekloudrepos/beta - As suggested by kurtulus.oz
For both approaches, I am seeing incorrect answer. Attached image.
The key instruction here is that you need to do the operation as user “natasha”, i.e., not use sudo. Both your approaches use sudo so the correct procedure is to do the following as natasha: