简体   繁体   English

在Git中跟踪文件权限。 运行git-cache-meta时出错:“发现:您有太多')'”

[英]Tracking file permissions in Git. Error running git-cache-meta: “find: you have too many ')'”

I'm currently trying to implement this recommendation to be able preserve file permissions while doing Git clones. 我目前正在尝试实施此建议 ,以便在执行Git克隆时能够保留文件权限。 However, when I run the command, I receive this error. 但是,当我运行命令时,我收到此错误。

$ git-cache-meta.sh --store
find: you have too many ')'

A previous error was in regards to having too many files being listed by Git (I have around 2.5GB worth of files which I am tracking which I understand is pushing the limits of a single Git project already). 先前的错误是关于Git列出的文件过多(我跟踪的文件大约有2.5GB,据我了解,这已经使单个Git项目的极限受到了限制)。

Is there something I had done wrong of the initialization of the shell script (I used the main code listed here : 我对shell脚本的初始化做错了什么吗(我使用了此处列出的主要代码:

1.  #!/bin/sh -e
2.  
3.  #git-cache-meta -- simple file meta data caching and applying.
4.  #Simpler than etckeeper, metastore, setgitperms, etc.
5.  #from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
6.  #modified by n1k
7.  # - save all files metadata not only from other users
8.  # - save numeric uid and gid
9.
10. # 2012-03-05 - added filetime, andris9
11.
12. : ${GIT_CACHE_META_FILE=.git_cache_meta}
13. case $@ in
14. --store|--stdout)
15. case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
16. find $(git ls-files)\
17.     \( -printf 'chown %U %p\n' \) \
18.     \( -printf 'chgrp %G %p\n' \) \
19.     \( -printf 'touch -c -d "%AY-%Am-%Ad %AH:%AM:%AS" %p\n' \) \
20.     \( -printf 'chmod %#m %p\n' \) ;;
21. --apply) sh -e $GIT_CACHE_META_FILE;;
22. *) 1>&2 echo "Usage: $0 --store|--stdout|--apply"; exit 1;;
23. esac

but I did not use any of the revisions, which seemed to be addressing separate problems). 但我没有使用任何修订版,这些修订版似乎正在解决单独的问题)。 Several of the reported errors on that page seemed to be in regards to specific characters in a file name, but looking through, I can't find any '(' or ')' that might raise the error I'm getting. 该页面上报告的一些错误似乎与文件名中的特定字符有关,但从头到尾,我找不到任何可能引起错误的'('或')'。

If it is related to trying to track too many files however, are there any recommendations as to maintain file permissions and owner meta-data while deploying it in Git? 但是,如果与尝试跟踪太多文件有关,那么是否有任何建议在将文件部署到Git时维护文件权限和所有者元数据?

Try this: 尝试这个:

function get_metadata {
    git ls-files | 
    xargs stat -c $'%a\t%U\t%G\t%x\t%n' | 
    while IFS=$'\t' read -r perm user grp date name; do 
        echo chown "$user" "$name"
        echo chgrp "$grp" "$name"
        echo chmod "$perm" "$name"
        echo touch -c -d "'$date'" "$name"
    done
}

case $1 in
    --stdout) get_metadata ;;
    --store)  get_metadata > "$GIT_CACHE_META_FILE" ;;
    --apply)
        [[ -f "$GIT_CACHE_META_FILE" ]] &&
        sh "$GIT_CACHE_META_FILE"
        ;;
    *) echo "usage: ..." ;;
esac

This assumes none of your filenames contain a newline. 假设您的文件名都不包含换行符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你如何使用git-cache-meta? - How do you use git-cache-meta? GIT。 我的道路已经存在 - GIT. I have path already exist 链接 VS 和 Git。 获取错误信息 - Linking VS and Git. Getting error message 推送到 Git 后没有看到任何变化。 Git 内部服务器错误 - No changes seen after pushing to Git. Git Internal Server Error GIT:git checkout .DS_Store错误:“错误:pathspec'.DS_Store'与git已知的任何文件都不匹配。” - GIT: git checkout .DS_Store error: “error: pathspec '.DS_Store' did not match any file(s) known to git.” 已经在git中重命名和修改了文件。 如何进行两次提交,一次提交重命名,一次提交内容? - Have renamed and modified file in git. How to make two commits, one for renaming and one for the contents? 不小心提交了一个大文件到本地git。现在我必须删除它才能推送到远程 - Accidentally committed a large file to local git. Now I have to remove it to push to remote 错误TF30170:“您正在使用的流程模板不支持Git。”创建团队项目时 - Error TF30170: “The process template you are using does not support Git.” when creating a team project R-studio 找不到 Git 的文件路径。 使用 M1 Macbook,版本 (11.2) - R-studio can't find file path for Git. Using M1 Macbook, Version (11.2) 失去了我在GIT的承诺。 你能不小心删除提交? - Lost my commit in GIT. Can you accidentally delete commits?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM