bla*_*bla 5 git file-permissions git-add
我有很多文件只有文件权限不同.但实际上有些文件被修改了.
我想将只有文件权限更改的所有文件添加到自己的提交中.
git --versiongit version 1.8.3.1
Run Code Online (Sandbox Code Playgroud)
git diff 输出:diff --git a/.htaccess b/.htaccess
old mode 100755
new mode 100644
diff --git a/.htaccess.sample b/.htaccess.sample
old mode 100755
new mode 100644
etc...
Run Code Online (Sandbox Code Playgroud)
git diff --name-statusM .htaccess
M .htaccess.sample
M robots.txt
M index.php
etc...
Run Code Online (Sandbox Code Playgroud)
git diff -G. --name-status
Run Code Online (Sandbox Code Playgroud)
输出:
M robots.txt
M index.php
Run Code Online (Sandbox Code Playgroud)
但是如何只添加具有更改权限的文件,这些可以提交?
编辑:
git diff-files100755 100644 fd0fa6002522f4f4bc46e4339671a6ea99969371 0000000000000000000000000000000000000000 M .htaccess
:100755 100644 383313a383445374f63364cd1985753e86418d04 0000000000000000000000000000000000000000 M .htaccess.sample
:100644 100644 e09ab6b6b0cf13a895d00ec97dae12d8ba2c364b 0000000000000000000000000000000000000000 M robots.txt
:100755 100644 56bdb6c86654bdba26b750d36db17b5e15279c86 0000000000000000000000000000000000000000 M index.php
etc...
Run Code Online (Sandbox Code Playgroud)
git diff-files输出看起来像我可以使用的东西.我有什么...
# Get all files that have changed content (save to ../found.list file)
$ git diff -G. --name-status | cut -d$'\t' -f 2 > ../found.list
# Get the diff-files that not have changed content
# This list holds all files that have changed permissions, but have no changed content
# so these are the files that need to be committed
$ git diff-files | cut -d$'\t' -f 2 | grep -Fxvf ../found.list
# Check if it worked
$ git diff-files | cut -d$'\t' -f 2 | wc -l
14951
$ git diff-files | cut -d$'\t' -f 2 | grep -Fxvf ../found.list | wc -l
14935
$ git diff -G. --name-status | wc -l
16
Run Code Online (Sandbox Code Playgroud)
这个命令似乎有效.但我认为有更简单的方法可以做到这一点.
git diff-files | cut -d$'\t' -f 2 | grep -Fxvf ../found.list | while read x; do git add $x; done
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
139 次 |
| 最近记录: |