Search code examples
gitrepositorygit-pull

How can I "pull" a git database without downloading the whole repository


I have the content of a huge project (with some changes) but not the Git database. One could get to the same situation for example like this:

  1. git clone <...>/repo.git
  2. cd repo
  3. echo "Blah" > new_file.txt
  4. rm .git

Since my repo is huge and all the project files are still there, I do not want to re-clone everything. How can I get back to a normal situation, where I would be able to commit and push my new_file.txt?

I tried searching in general and among other questions here but nothing seems to provide the answer for this specific situation.


Solution

    1. Clone the repository using git clone --no-checkout into another directory, say dir.
    2. Copy dir/.git to your repo.
    3. Go to your repo and run git reset.