Symbolic Link to a Hook in Git

Symbolic link to a hook in git

you just used wrong path, it should be:

ln -s -f ../../hooks/post-merge .git/hooks/post-merge

Git hooks for symlink convertion on Windows

Rather than using a hook, you could try using a smudge filter. They're more designed to change the content of text files than of symlinks, but I think you could get them to work.

Some documentation here: http://git-scm.com/docs/gitattributes#__code_filter_code

Can I create a symbolic link automatically after git clone

No.

This is intentional. The creators of git wanted to make sure that code could never be run just by cloning a repository. Otherwise, git hooks would be a great way to deliver malware.

If your users choose to trust your pre-commit hooks, they have to manually enable them. If you want, you can use server-side hooks to reject changes that don't meet your standards.

Symlink to folder with custom hooks in GitLab

Final solution:

  1. in /opt/gitlab/embedded/service/gitlab-shell/hooks/ create folders post-receive.d, pre-receive.d, update.d and myhooks
  2. in myhooks create hook-chain script and proper hooks to run by it
  3. in first three folders create symlinks to script hook-chain in myhooks, like:

    [root@server ~]# ll /opt/gitlab/embedded/service/gitlab-shell/hooks/update.d/
    total 4
    lrwxrwxrwx 1 gitlab gitlab 68 Apr 18 08:47 update -> /opt/gitlab/embedded/service/gitlab-shell/hooks/myhooks/hook-chain
  4. of course user gitlab has to be owner of all scripts

Git symbolic links in Windows

You can find the symlinks by looking for files that have a mode of 120000, possibly with this command:

git ls-files -s | awk '/120000/{print $4}'

Once you replace the links, I would recommend marking them as unchanged with git update-index --assume-unchanged, rather than listing them in .git/info/exclude.

How can I get Git to follow symlinks?

NOTE: This advice is now out-dated as per comment since Git 1.6.1. Git used to behave this way, and no longer does.


Git by default attempts to store symlinks instead of following them (for compactness, and it's generally what people want).

However, I accidentally managed to get it to add files beyond the symlink when the symlink is a directory.

I.e.:

  /foo/
/foo/baz
/bar/foo --> /foo
/bar/foo/baz

by doing

 git add /bar/foo/baz

it appeared to work when I tried it. That behavior was however unwanted by me at the time, so I can't give you information beyond that.



Related Topics



Leave a reply



Submit