如何在Windows上的Git中创建文件执行模式权限? [英] How to create file execute mode permissions in Git on Windows?

查看:380
本文介绍了如何在Windows上的Git中创建文件执行模式权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows中使用Git,并希望通过一次提交将可执行shell脚本推送到git repo中。通常,我需要执行两个步骤(<$ c
$ b

  $ vi install.sh 
$ git add git commit
)。 install.sh
$ git commit -am添加新文件进行安装#第一次提交
[master f2e92da]添加对install.sh的支持
1个文件已更改,18个插入(+), 3删除( - )
创建模式100644 install.sh
$ git update-index --chmod = + x install.sh
$ git commit -am更新文件权限#第二次提交
[master 317ba0c]更新文件权限
0文件已更改
模式更改100644 => 100755 install.sh

如何将这两个步骤合并为一个步骤? git配置? Windows命令?



参考:请参阅 Windows上的Git文件权限中的问题。 for second commit

解决方案

在两次提交中不需要这样做,您可以添加文件并将其标记为可执行文件commit:

  C:\Temp\TestRepo> touch foo.sh 

C:\\ \\Temp\TestRepo> git add foo.sh

C:\Temp\TestRepo> git ls-files --stage
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo.sh

当您注意到,添加后,模式为0644(即不可执行)。但是,我们可以在提交之前将它标记为可执行文件:

  C:\ Temp \ Teststop> git update-index  - chmod = + x foo.sh 

C:\Temp\TestRepo> git ls-files --stage
100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 foo.sh

  $ b 

现在文件是模式0755(可执行文件)。 code> C:\Temp\TestRepo> git commit -m可执行文件!
[master(root-commit)1f7a57a]可执行文件!
1文件已更改,0插入(+),0删除( - )
创建模式100755 foo.sh

现在我们只需一次提交一个可执行文件。


I use Git in Windows, and want to push the executable shell script into git repo by one commit.

Usually I need to do two steps (git commit).

$ vi install.sh
$ git add install.sh  
$ git commit -am "add new file for installation" # first commit
[master f2e92da] add support for install.sh
 1 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 install.sh
$ git update-index --chmod=+x install.sh
$ git commit -am "update file permission"        # second commit
[master 317ba0c] update file permission
  0 files changed
  mode change 100644 => 100755 install.sh

How can I combine these two steps into one step ? git configuration ? windows command ?

Reference: see question in Git file permissions on Windows for second commit

解决方案

There's no need to do this in two commits, you can add the file and mark it executable in a single commit:

C:\Temp\TestRepo>touch foo.sh

C:\Temp\TestRepo>git add foo.sh

C:\Temp\TestRepo>git ls-files --stage
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       foo.sh

As you note, after adding, the mode is 0644 (ie, not executable). However, we can mark it as executable before committing:

C:\Temp\TestRepo>git update-index --chmod=+x foo.sh

C:\Temp\TestRepo>git ls-files --stage
100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       foo.sh

And now the file is mode 0755 (executable).

C:\Temp\TestRepo>git commit -m"Executable!"
[master (root-commit) 1f7a57a] Executable!
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100755 foo.sh

And now we have a single commit with a single executable file.

这篇关于如何在Windows上的Git中创建文件执行模式权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆