所以我注意到,由于git根据文件系统中的分支名称命名文件夹(特别是在refs文件夹中,即遥控器),这可能会导致问题,因为文件夹名称中允许的字符与操作系统有关。
例如,您可以在MAC OS上创建分支,如:
feature/my_special_"Splash Screen"_feature
如果我在Windows上获取此内容,它会失败并显示如下消息:
Fetch failed: fatal: Unable to create 'C:/AndroidStudioProjects/MyProject/.git/refs/remotes/origin/feature/my_special_"Splash Screen"_feature.lock': Invalid argument
由于文件名包含Windows上不允许的使用权,但在MAC OS上允许使用。
当您尝试在Windows上创建相同的分支时,git将只删除反语。
有没有人知道这方面的官方文件?另外,我们是否需要重命名此分支或是否有解决方法?
答案 0 :(得分:3)
“Legal Git branch names”中提及了一项非官方政策,引用了this thread:
Git分支名称不能:
- 有一个以“。”
开头的路径组件- 有一个双点“..”
- 拥有ASCII控制字符,“〜”,“^”,“:”或SP,任何地方
- 以“/”
结束- 以“.lock”结尾
- 包含“\”(反斜杠)
That patch (for a better error message on invalid branch name) was not implemented,当时不包含双引号。
但是,最好避免在分支名称中使用任何特殊字符。
This comment in refs.c仍然是最接近官方政策的:
/*
* Try to read one refname component from the front of refname.
* Return the length of the component found, or -1 if the component is
* not legal. It is legal if it is something reasonable to have under
* ".git/refs/"; We do not like it if:
*
* - any path component of it begins with ".", or
* - it has double dots "..", or
* - it has ASCII control characters, or
* - it has ":", "?", "[", "\", "^", "~", SP, or TAB anywhere, or
* - it has "*" anywhere unless REFNAME_REFSPEC_PATTERN is set, or
* - it ends with a "/", or
* - it ends with ".lock", or
* - it contains a "@{" portion
*/