How, using git in Windows, indicate that the file is allowed to run in Unix environments?

Asked

Viewed 121 times

4

I’m using git in development, and I’m willing to put the project gradle to be executed in the IC. To execute the gradle, just give a ./gradlew to start the process. However, when calling this in my IC, it complains that the file gradlew is not executable.

However, I am unable to change the permission of this file, as everyone on the team uses Windows and chmod +x in Windows is no-op, even about git-bash.

So, how to indicate to git change the permission to run a file, through Windows?

I don’t care here "fix" this problem at IC level, calling chmod +x before the execution of the command.

  • 1

    I understand the need totally, I have some . sh that I go through it (gradlew is one), but it will be run sh ./gradlew would already solve?

  • Yes, it would solve at "IC level", as the chmod +x. But here the intention is more general.

  • I’m so used to sh, which is a very short command, which I don’t really care about, but I understand that when it comes to teamwork, usually other employees are much more likely to lack minimum understanding, or even need. If this is your need.

  • 1

    He even tried git update-index --chmod=+x caminho/gradlew in Windows?

  • I was hoping someone would answer that xD By the way, it works (needed the --add when I went stir today but details...)

  • It’s just that I’m running out of linux to download and test to see if it worked, so I didn’t answer, but I’m glad I already knew, adding content to the site, is what I like the most :)

Show 1 more comment

1 answer

4


To list a file with a different mode, use the git update-index, with the option --chmod=+x.

I had to do it to make a Bash script hbm.sh executable:

$ git update-index --chmod=+x hbm.sh

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   hbm.sh


$ git diff

$ git diff HEAD
diff --git a/hbm.sh b/hbm.sh
old mode 100644
new mode 100755

An important detail to note is that the file permissions option needs to be done before the names of the archives. Then git update-index arquivo.sh --chmod=+x does not give the effect of changing file permissions arquivo.sh, but git update-index --chmod=+x arquivo.sh gives the expected result.

When I needed to do this with the gradlew, I needed to add the option --add at the command line:

$ git update-index --chmod=+x --add gradlew

This was necessary because the file gradlew it wasn’t traced, it wasn’t even listed/staged.

  • 1

    Thanks for the collaboration, thanks to this I updated 2 projects to simplify.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.