admin管理员组

文章数量:1278986

I like to keep a copy of my /etc folder in a git repository. That way, if something changes and breaks but I don't notice it right away, I'm likely to have a diff that helps me recover pretty quickly.

However, the point is to also make that git repository a form of backup. So I was thinking that I should move the .git folder to a different drive. To do so, I was thinking to use a softlink:

# mv /etc/.git /mnt/other-drive/safe-git
# ln -s /mnt/other-drive/safe-git /etc/.git

Is that possible? Is git ignoring the fact that the .git folder could be a symlink?

I like to keep a copy of my /etc folder in a git repository. That way, if something changes and breaks but I don't notice it right away, I'm likely to have a diff that helps me recover pretty quickly.

However, the point is to also make that git repository a form of backup. So I was thinking that I should move the .git folder to a different drive. To do so, I was thinking to use a softlink:

# mv /etc/.git /mnt/other-drive/safe-git
# ln -s /mnt/other-drive/safe-git /etc/.git

Is that possible? Is git ignoring the fact that the .git folder could be a symlink?

Share Improve this question asked Feb 24 at 0:11 Alexis WilkeAlexis Wilke 20.8k11 gold badges104 silver badges177 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 4

You can use a symlink on OSes that have those, or Git understands a regular-file .git with gitdir: path/to/that too, it'll treat the given path like a symlink'd path.

You can move .git repository anywhere and set git config core.worktree /etc. Or GIT_DIR/GIT_WORK_TREE environment variables, or --git-dir/--work-tree command-line options.

本文标签: backupIs it okay to use a symlink for my local git folderStack Overflow