Clone only .git directory of git repository

I have a repo synchronized with Google Drive, but my .git directory was disabled, so it is now uploaded to Google Drive.

I recently formatted the machine Gentoo, and after all the Google Drive files were synced again, I realized that the directory .gitdoes not exist.

The problem is that I don’t remember if I had any unmarked / unmanaged changes in local and not in github.

I searched, but I only found answers to the opposite question (Cloning without a directory .git)

I do not want to make git clonemy repo until I am sure that possible local changes will not be lost.

Is there a way to clone only folders .gitand then push any local changes that I may have on my machine?

+4
source share
3 answers

I solve it. It was a simple process:

  • I cloned the repo to another place, e.g. (at /tmp)
  • I copied the folder .gitto the source directory folder
  • I made a git statusrepo in my source folder and all local changes were there.

Hope this helps others.

+3
source

One-step solution:

git clone --no-checkout <repo_url>

or if you already have an empty directory,

cd myrepo
git clone --no-checkout <repo_url> .
+4
  • Make git cloneto another folder on your computer from your online repo
  • Pay attention to the branch in which you are interested in comparing your local files.
  • Then copy / paste the contents of the folders on top of the new clone.
  • See what has changed (if anything and commit, as you would).
+2
source

Source: https://habr.com/ru/post/1651559/


All Articles