blob: 8a2f612b56aa7222afeb5097737da5448a733a47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
+++
title = "Cool things I didn't knew: multiple Git repositories in a single directory"
author = ["Michał Sapka"]
date = 2024-10-29T22:51:00+01:00
categories = ["blog"]
draft = false
weight = 2001
image_dir = "blog/images"
image_max_width = 600
Abstract = "How to combine files from multiple repositories in one directory?"
Listening = "John Coltrane - A Love Supreme"
+++
I am trying to find a nice way to add sync to my org.
I can't use any syncthing nor dropbox on my work computer, but I won't ever put google drive on my personal one.
When asked on Mastodon, people proposed me to use git.
I'm sure you know that `git worktree` allows you to have multiple branches available at the same time.
But, did you knew that the `.git` folder, although standard, is not mandated?
In fact, all your git data can live anywhere.
First, you need a standard `.git` folder, so let's
```shell
git init
mv .git .git-one
```
Now, if you `git status`, there won't be no git repository found.
But we can force git to use our new dir
```shell
git --git-dir=.git-one status
```
This tricks allows us to have any number of git repositories co-exist in the same directory.
Those can share files (just `git add` them), or be completely different.
So, want to have a `work_org` and `private_org` side by side?
No problem!
Each repository has it own:
- origin
- staging area
- history
and so on.
Pretty cool, I might add.
|