Codespaces执行git commit设置chmod=+x后同步卡住无法推送
解决GitHub Codespaces同步权限变更卡住的问题
问题场景
文件初始状态不可执行:
git ls-tree HEAD > 100644 blob <somekey> postCreateCommands.sh
执行命令设置可执行权限并提交变更:
git update-index --chmod=+x postCreateCommands.sh git commit -m "fix: changing file permissions" > mode change 100644 => 100755 .devcontainer/postCreateCommands.sh
但点击「Sync Changes」按钮后,Codespaces同步进程卡住,已提交的变更无法推送到远程仓库。
可行解决方法
- 直接用命令行推送:跳过Codespaces的UI同步流程,在终端执行推送命令:
这是绕开UI同步bug最直接的方式。git push - 检查并开启Git权限跟踪:确认本地Git是否开启文件权限变更跟踪,执行命令查看配置:
若输出为git config core.filemodefalse,执行以下命令开启:
完成后重新提交并尝试推送。git config core.filemode true - 重启Codespaces实例:部分情况是环境缓存导致的异常,关闭当前Codespaces实例后重新打开,再尝试推送变更。
- 撤销提交后重新操作:如果上述方法无效,先撤销当前提交,重新设置权限并提交推送:
git reset HEAD~1 git update-index --chmod=+x postCreateCommands.sh git add . git commit -m "fix: update file permissions to executable" git push
内容的提问来源于stack exchange,提问作者BlimBlomBlum
相关产品推荐
相关产品推荐

