How to Selectively Create Symbolic Links to Specific Files in Another Directory in Linux

How do I selectively create symbolic links to specific files in another directory in LINUX?

Assuming you are in a directory that contains directories bar1 and bar2:

find bar1 -name '*foo*' -not -type d -not -name '*.cc' -exec ln -s $PWD/'{}' bar2/ \;

Linux: My symbolic links are coming out as broken

    ln -s "$PWD/$pathname" "$mods/$name"

What could I be doing wrong?

As $pathname is already absolute, it's the prepending of $PWD/ which does harm; just drop that.

How to use submodules publicly, but symlinks to a single clone locally?

So Git apparently sees the fact that it's a symbolic link, instead of following through to the directory.

Yes, Git would see such a change, because that submodule is declared in the parent repo as a special entry in the index.

Making a symlink would replace that special entry by a file of another type.

What you could do is try playing with GIT_WORK_TREE (as in "Including submodules in git checkout to GIT_WORK_TREE in hook").

But a more simpler solution would be to:

  • keep your submodule right where they are.
  • add another clone of that submodule repo where you want it (/path/to/sub).
  • detect any changes from the original submodule folder with a git --work-tree=/path/to/sub status from within your duplicated submodule folder in your parent repos.


Related Topics



Leave a reply



Submit