-3

I created a bare Git repository on a shared drive on my company's server. I have cloned it on my own machine's C drive.

If my machine dies tonight, will everything I have pushed to that bare Git repository be safe? That is, will I be able to just use another machine and clone it, and have everything I've worked on?

Thanks Tom

Tom
  • 97
  • 4
  • 2
    Isn't that the whole point of a distributed VCS? – crashmstr Dec 01 '17 at 17:06
  • If you have only commited to your cloned repo, no. If you have also pushed your commits back to the remote, then yes – alechill Dec 01 '17 at 17:07
  • These two are good candidates for duplicates of this question (though I admit their focus is different): https://stackoverflow.com/q/5540883/1256452 and https://stackoverflow.com/q/7861184/1256452 – torek Dec 01 '17 at 17:49
  • Yes but if your machine die, you will probably see that your only remaining repository has some corrupted files. Perhaps you should envisage to do a `git bundle` some time to time and store it somewhere else... – Philippe Dec 01 '17 at 17:50

2 Answers2

1

I created a bare Git repository on a shared drive on my company's server. I have cloned it on my own machine's C drive.

If my machine dies tonight, will everything I have pushed to that bare Git repository be safe? That is, will I be able to just use another machine and clone it, and have everything I've worked on?

In general, the answer is "yes." Any work that you have pushed to the remote will be stored, and can be cloned or pulled into a repository on another system. Any work that hasn't been pushed, whether committed locally or not, will be lost.

As a caveat, how your machine dies can have an impact. As one example, if you have had a failing disk that's been corrupting your data for a while, and have been pushing corrupted data upstream as a result, then the chances are good that there will be corrupted data upstream as well. Because of the way Git stores data, you can usually recover up to the point of corruption as long as you haven't been using forced pushes of rebased branches, but your mileage may vary. Other edge cases like failure during a push are less likely to be problems.

A distributed VCS is resistant to corruption and loss of data, but is not totally immune to it. While it will no doubt be fine in your defined use case, you really ought to incorporate a backup scheme into your high-availability and data integrity planning.

Community
  • 1
  • 1
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
0

the files are in the .git folder, but stored in a GIT way. You don't really see them. If you run git clone ... you have a clone in the new location.

Chad
  • 1,139
  • 17
  • 41