0

As in the title, how can I backup completely a local Git repository and its state, restore it on another machine, and have the new repository to be in the exact state as the one on the previous machine?

I mainly care to not loose local stuff, like:

  • stashes (that's the most important thing)
  • reflog (I want to keep my operations history)
  • notes
  • all the rest (possibly)

EDIT

I already tried to compress my local directory, including hidden files like .git, and restore it on the other machine.

What I get, after that, with git status is:

  • a HUGE list of changed files (and I don't recognize the changes)
  • the repository is in a detached HEAD

If everything is in the .git folder, why I get the HEAD detached and I don't get the same pointing of the old repository?

And what are all these modified/deleted/typechanged files?

It seems that .git is not really taking everything from the old repository.

Kamafeather
  • 8,663
  • 14
  • 69
  • 99
  • You did something wrong when compressing and restoring. Detached HEAD or not is stored in a simple text file `.git/HEAD`, it's not a state that you may lose by copying to another machine. – Matthieu Moy Jun 07 '15 at 22:49

1 Answers1

2

If you copy/paste your whole directory from one machine to the other (including hidden files like .git, ...), you will be keeping:

  • stashes (that's the most important thing)
  • all your history, including all local branches, ...
  • notes

Git always stores the data of one repository inside the .git repository, and nowhere else

edi9999
  • 19,701
  • 13
  • 88
  • 127
  • Yeah I was trying that but I asked because I got the result that I explained in the **EDIT** of my original question. There are effects that I cannot explain; and that doesn't assure me that everything went wrong; I suspect something else could have changed. – Kamafeather Jun 05 '15 at 09:34