git git 提交期间修改内容错误

git modified content error during git commit

更新-1

这就是我想要做的。

cd /tmp
git clone http://git.example.com/foo/openstack.git -b ansible-roles ansible-roles-new
cd ansible-roles-new
cp -r /etc/ansible/roles /tmp/ansible-roles-new

在那之后我做了 git commit -m "foo..." 和 运行 git status 但它显示 modified content 不知道为什么并且不让我 git push :(

这是我里面的目录结构ansible-roles-new folder

[root@foo ansible-roles-new]# ls -l /tmp/ansible-roles-new/roles/
total 196
drwxr-xr-x 16 root root 4096 Jun 24 22:43 ansible-hardening
drwxr-xr-x 12 root root 4096 Jun 24 22:43 apt_package_pinning
drwxr-xr-x  9 root root  203 Jun 24 22:45 bird
drwxr-xr-x 13 root root 4096 Jun 24 22:45 os_cinder
drwxr-xr-x 15 root root 4096 Jun 24 22:43 ceph_client
drwxr-xr-x 11 root root 4096 Jun 24 22:43 config_template
drwxr-xr-x 10 root root  219 Jun 24 22:45 etcd
drwxr-xr-x 14 root root 4096 Jun 24 22:43 galera_client
drwxr-xr-x 15 root root 4096 Jun 24 22:43 galera_server
...
...
...
many more...

这是非常难运行的事情。

[root@foo ansible-roles-new]# git status
# On branch ansible-roles
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   roles/os_cinder (modified content)
#   modified:   roles/os_keystone (modified content)
#   modified:   roles/os_magnum (modified content)
#   modified:   roles/os_octavia (modified content)
#   modified:   roles/rabbitmq_server (modified content)
#   modified:   roles/rsyslog_client (modified content)
#
no changes added to commit (use "git add" and/or "git commit -a")

所以这就是我所做的,根据谷歌搜索,似乎当我复制角色目录时它已经有一些 .git 文件,所以我确实像下面这样清理了。

[root@foo ansible-roles-new]# rm -rf roles/os_cinder/.git*

做了git初始化

[root@foo ansible-roles-new]# git init
 Reinitialized existing Git repository in /tmp/ansible-roles-new/.git/

但它没有再次创建 .git 目录,看起来它也不再跟踪该目录了。

我错过了什么吗?

运行 git-1.8.x

编辑:

如果我修改了 roles/os_cinder 目录中的任何内容,它就不会再跟踪并且不会检测到任何更改。

git diff 说它很脏但不确定在哪里?

@@ -1 +1 @@
-Subproject commit ff5207066cfef8eb380c35d398a884d357e2738d
+Subproject commit ff5207066cfef8eb380c35d398a884d357e2738d-dirty
diff --git a/ansible-roles-new/roles/os_cinder b/etc-ansible/roles/os_cinder
--- a/ansible-roles-new/roles/os_cinder
+++ b/ansible-roles-new/roles/os_cinder
@@ -1 +1 @@

这是我发现的。当我从 public github.com 回购检出 ansible/roles 时,它已经有一些 .git ancher。后来当我试图在导致上述问题的内部 git 服务器中移动同一个文件夹时。

清理完所有 .git 之后它就可以工作了。

for qw in `ls /etc/ansible/roles`; do  rm -rf /etc/ansible/roles/$qw/.git*; done