Assign execute permissions with Git

Published: 24 January 2016

Recently I had to configure a build on Jenkins, and ran into an issue with a shell script that did not want to execute and failed with a “Permission Denied” error.

Being new to the Linux world I reached out to a colleague and it turned out the solution was an easy one. It is new for me, so I am sharing it so it can maybe help you in the future.

The solution is to use the Git update-index command to assign the execute permissions.

Let’s say the bash script in question is named, then go to your shell (or Git shell if you’re on Windows like me) and execute the following command:

git update-index --chmod=+x

This will assign execute permissions to the bash file. After that you can commit the changes to the repo.

Hope this helps someone out there :)

If you found value in this blog post and want to return the favour, you can Buy me a coffee

PS: I publish a weekly newsletter for ASP.NET Developers called ASP.NET Weekly. If you want to get an email every Friday with all the best ASP.NET related blog posts from the previous week, please sign up!