0

I am developing on Windows and uploading to a Linux cloud server using git, via Bitbucket.

I edited a shell script, which on Windows has permissions

-rwxr-xr-x

For some reason, when it gets to Linux, it has permissions

-rw-r--r--

To make it executable I do:

chmod +x <my_script>.sh

Later, I edit the script back on Windows and push the changes up to Bitbucket. When I try to

git pull

back on the cloud I get the following error:

error: Your local changes to the following files would be overwritten by merge:
        <path>/<my_script>.sh
Please commit your changes or stash them before you merge.
Aborting

All I did on the cloud was make the file executable. I didn't edit it! Can I tell git to get on with the merge and ignore file permissions? If not, how best to deal with this situation?

I realize I could unset the permissions

chmod -x <my_script>.sh

do the pull, and then reset the permissions

chmod +x <my_script>.sh

But to have to do this each time I edit is a pain. Is there a better way?

4
  • Try sh myscript.sh instead Nov 11, 2019 at 14:52
  • @davidbaumann I hear you. This way I don't need to change the permissions. But...I'd still like to know if I can tell git to ignore the permissions. After all, the text has not been touched. And sometimes I just get an itchy trigger finger and want to make my shell scripts executable :->.
    – Argent
    Nov 11, 2019 at 15:17
  • 1
    Maybe this: stackoverflow.com/questions/1580596/… Nov 11, 2019 at 15:19
  • @davidbaumann Thanks for the link. It seems to be what I want.
    – Argent
    Nov 11, 2019 at 23:43

1 Answer 1

0

You can configure git to ignore the executable bit:

git config --global core.fileMode false

See more details here:

man git-config

Actually found this here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .