summaryrefslogtreecommitdiffstats
path: root/content/posts/recovering-deduplicated-git-repositories.md
diff options
context:
space:
mode:
authorPeter2022-05-10 11:23:40 +0100
committerPeter2022-05-10 11:23:40 +0100
commit3a3a7d9670e625a97df85a744d14bcd344e82923 (patch)
tree2ef0128aebde9411910308d30d80dc53913d0a2e /content/posts/recovering-deduplicated-git-repositories.md
parent8eadb0289cae0f3e4b22089cf81fcbd23d2da8bd (diff)
downloadblog.minskio.co.uk-3a3a7d9670e625a97df85a744d14bcd344e82923.tar.gz
blog.minskio.co.uk-3a3a7d9670e625a97df85a744d14bcd344e82923.tar.bz2
blog.minskio.co.uk-3a3a7d9670e625a97df85a744d14bcd344e82923.zip
New and updated posts
Diffstat (limited to 'content/posts/recovering-deduplicated-git-repositories.md')
-rw-r--r--content/posts/recovering-deduplicated-git-repositories.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/content/posts/recovering-deduplicated-git-repositories.md b/content/posts/recovering-deduplicated-git-repositories.md
new file mode 100644
index 0000000..e67f46a
--- /dev/null
+++ b/content/posts/recovering-deduplicated-git-repositories.md
@@ -0,0 +1,25 @@
+---
+title: "Recoving de-duplicated git repositories"
+date: 2022-05-05T15:37:00
+tags: ["Linux", "Recovery", "Snippets", "Software"]
+---
+
+I have a number of software projects in a single directory, using `git` for version control which is shared across most of my computers using `syncthing`.
+
+Late one night, I wanted to de-duplicate a folder full of files I'd been working on over the course of a few weeks. I'd work through a directory then as part of my 'completing' the work, would de-duplicate it using `jdupes` to ensure no files were duplicated. I'm sure you can see where this is going.
+
+As part of my workflow, I was navigating directories, tapping the up arrow to repeat my last command and hitting enter with reckless abandon. I noted the command took a little longer than usual and immediately realised what I'd done. I went to assess the damage, when browsing using git, cgit, or even the github desktop client, all my repositories were broken except for a single bare repository.
+
+The first thing to do is to find any potentially affected directories. This can simply be done via `find . -type d -name '.git'`. As what was deleted will only ever be duplicated content, you should be able to rebuild these repositories quite easily with the following:
+
+```
+cd affected-project
+mv ".git" ".gitcontents"
+git init
+rsync --remove-source-files -av ".gitcontents" ".git"
+find ".gitcontents" -empty -delete
+```
+
+Which should get you up and working again.
+
+The moral of the story is to keep a backup, and then make a backup of your backup (just in case). \ No newline at end of file