'I cut/pasted a folder into a local repository mid-clone - the clone failed and the folder disappeared. Is the folder I pasted gone forever?

I wanted to put my local code into a GitHub repository.

I created a repo on GitHub and tried cloning with HTTPS.
The clone was taking a moment but the folder was created on my laptop so I decided to cut/paste my local code into the local repo folder.

Well, the clone ended up failing and the repo folder just disappeared, along with all of its contents.
The folder I added to the local repo also disappeared.
I can't even find it in the recycling bin. Is it gone forever?



Solution 1:[1]

Next time:

  • make sure you have installed gh, the GitHub CLI
  • create a repository locally where your code is
  • publish to GitHub (that will create the remote repository)

That way, no clone, no hazardous code migration.

The command to create the remote repository is (after a gh auth login):
gh repo create.

Inside a git repository, and with no arguments, gh will automatically create a repository on GitHub on your account for your current directory, using the directory name.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC