Clone only the .git directory of a git repo

I have a repo in sync with google Drive, but I had the .git directory ignored so it is now uploaded to Google Drive.

Recently I formatted my Gentoo machine and after I had all Google Drive files synced again I realized the .git directory was not there.

  • How to manage collaborator rights in Github?
  • How do I do “git update”?
  • Collaboration on wordpress site git. How to share database?
  • Angular.js Tutorial using the Node.js webserver
  • “Invalid description in FETCH_HEAD” pull / sync in Visual Studio
  • Can I return a message from a python git pre-receive hook prefixed error: instead of remote:
  • The problem is I do not remember if I had some unstagged/uncommited changes in local not pushed to github.

    I have been searching but I only found answers for the opposite question (Cloning without the .git directory)

    • How do I clone a subdirectory only of a Git repository?
    • Cloning only a subdirectory with git
    • How to clone git repository only some directories?
    • Is it possible to clone only part of a git project?
    • Git Clone: Just the files, please?
    • Git clone without .git directory

    I do not want to make a git clone of my repo until I am sure that possible local changes are not going to be loss.

    Is there any way of cloning only the .git folder and then push any local changes that I may have in my machine?

  • How to remove git user from config?
  • How to create a coding tutorial with snapshots in Git
  • git svn error after change the svn repo address
  • GIT - branches not closing after merge
  • Git push failed, “Non-fast forward updates were rejected”
  • How to always have the latest working copy of a git repo?
  • 2 Solutions collect form web for “Clone only the .git directory of a git repo”

    I solve it. It was an easy process:

    1. I’ve cloned the repo to a different location eg (in /tmp)
    2. I’ve copied the .git folder into my original repo folder
    3. I did git status on my original repo folder and all the local changes were there.

    Hope it helps others

    1. Do a git clone to a different folder on your machine from your online repo
    2. Checkout the branch that you’re interested in comparing your local files against.
    3. Then copy/paste your folders contents over top the new clone.
    4. Check to see whats changed (if anything and commit as you would).
    Git Baby is a git and github fan, let's start git clone.