Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In sourcetree for windows, how to chmod set executable permission bit?

How can sourcetree windows users set the executable bit on some files before pushing?

It is a common problem if sysadmins use sourcetree on windows to manage scripts (*.sh, *.py, and so on) that need to be executable when they're pulled on a remote linux system.

So far, the only solution I've found is to open a Terminal window, and run the command:

git update-index --chmod=+x <your_file>

It seems like this must be a common enough situation to deserve a simpler solution, like right-clicking a file and "set executable" or by some setting in .gitattributes, but so far, I can't find any solution like that.

I also know you can define a Custom Action, but it's very surprising if something this common truly requires you to put that much effort into setup in advance.

Is there any better solution possible?

like image 413
Edward Ned Harvey Avatar asked Mar 07 '18 18:03

Edward Ned Harvey


1 Answers

I ended up creating a custom action.

  • From the menu, select "Tools", "Options"

  • In the dialog window, select the "Custom actions" tab

  • In the "Custom Actions" panel, press the "Add" button

    Custom Actions, Add

  • In the "Edit custom action" dialog:

    • in the "Menu caption" box, enter your action description (eg.: Mark as executable)
    • in the "script" box, enter "git"
    • in the "parameter" box, enter "update-index --chmod=+x $FILE"
    • press "OK" and close all the dialogs to apply the changes Edit custom action dialog

From now on, you can mark a committed file as executable while selecting it and applying the custom action.

Apply custom action

like image 143
Starnuto di topo Avatar answered Oct 19 '22 05:10

Starnuto di topo