Home > database >  I cloned a GitHub repository in git and I can't find it now
I cloned a GitHub repository in git and I can't find it now

Time:04-22

I'm new using git and my teacher gave an assignment "1) create a project called "project 1" and a folder called "study", clone it to you computer" I did this but now I can't find where is it

CodePudding user response:

Search for a file that contains the repo URL

A repo managed by git has a .git/ folder where it stores all the info git needs to do its job. One of those files, .git/config contains a list of all the remotes you have configured; since you cloned this repo from github (instead of creating a new repo on your local machine, which might not have any remotes yet), it is guaranteed that the repo URL will exist as plain text inside this file.

Search your entire hard-drive for any files that contain the repo. This should work in bash, which you can use on Mac or just about any *nix computer:

find / -type f -ipath "*/.git/config" 2>/dev/null | xargs grep -i "github"

What does this do?

  • find / means search the entire file tree, i.e. all local drives
  • -type f means limit the search to files (i.e. not directories)
  • -path "*/.git/config" means we're looking for files named config that are directly inside a folder named .git, and we don't care where that folder is
  • 2>/dev/null means to hide any find errors by redirecting stderr to /dev/null (i.e. instead of printing them)
  • | xargs grep takes the list of files that are found and then performs a full-text search on their contents
  • -i "github" means to match files that contain the text "github" (ignoring lettercase)

This command will take a minute or two to execute, because it is searching your entire computer.

CodePudding user response:

In windows; go to File explorer and then in the search box (top right corner) search for .git.

  • Related