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:
- in
/opt/gitlab/embedded/service/gitlab-shell/hooks/
create folderspost-receive.d
,pre-receive.d
,update.d
andmyhooks
- in
myhooks
createhook-chain
script and proper hooks to run by it in first three folders create symlinks to script
hook-chain
inmyhooks
, 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-chainof 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
Gentoo Crontab: Why This Simple Crontab Is Not Working
How to Clear All History in Linux/Ubuntu Terminal or Bash Permanently
Suppress Echo of Command Invocation in Makefile
How to Insert a New Line in Linux Shell Script
How I Should Run My Golang Process in Background
How to Pipe Output from Grep to Cp
How to Start Postgresql Service on Centos 7
How to Mount an Iso Inside a Docker Container
Automatic Docker Login Within a Bash Script
How Does the Linux Kernel Determine the Order of _Init Calls
Passing Main Script Variables into Perl Modules
Diff to Output Only the File Names
Total Size of the Contents of All the Files in a Directory
How to Call Curl Without Using Server-Side Cache
Compress Files While Reading Data from Stdin
How to Determine the Current Ip from a Known MAC Address
How to Check That Two Folders Are the Same in Linux
Setting Up Permissions for Wordpress on Amazon Ec2 (Amazon Linux)