9

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?

Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45
  • *It seems like this must be a common enough situation to deserve a simpler solution, like right-clicking a file* I very much doubt it's a common situation. People who work with `*.sh` quite seldom work with w32 at all, and even if they work they prefer command line. I surely prefer CLI over any GUI. – phd Mar 08 '18 at 15:28
  • I for one am in that same situation. I much prefer Windows to work on, but my work consists to a large extent of building Java applications that run on Docker. Edward Ned, you're not alone! – Quirijn Aug 25 '18 at 08:40
  • 3
    @Quirijn, thanks. I think it's hilarious when somebody says "I think the thing you're trying to do is not common," as if that's helpful in any way. The fact of the matter is, very few people use linux as a desktop; almost all are mac or windows. All the devops people out there need to maintain scripts on mac and windows. Problem is easy to workaround in mac, but not windows. ¯\\_(ツ)_/¯ – Edward Ned Harvey Aug 30 '18 at 02:17
  • I too am looking for a more seamless solution to this conundrum. Given the preponderance of different operating systems being used all at the same time the same development environment, this is becoming a major headache. Windows, Linux, Macintosh, Android, iOS and more, all being used at the same time and on the same development effort means that a seamless solution is a must. – Richard Sep 20 '18 at 00:39
  • @EdwardNedHarvey you are not alone by any means! FYI - I raised a pull request to the "gitextensions" project to add just such a menu option. Its currently up for discussion: https://github.com/gitextensions/gitextensions/pull/6135 – tip2tail Jan 21 '19 at 21:44

1 Answers1

3

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
Starnuto di topo
  • 3,215
  • 5
  • 32
  • 66