【问题标题】:Git revert file mode to 755Git将文件模式恢复为755
【发布时间】:2022-01-06 00:06:07
【问题描述】:

我们的一位开发人员设法将 shell 脚本的文件模式从 755 更改为 644,并将其提交到原始分支。我想把它改回 755 但 Git 不会合作。我在 Linux bash 中工作,在 Linux 文件系统上(在 WSL2 中)。

这是我期望应该起作用的(事实上它确实在大约同时创建的另一个分支上工作,对同一个文件有相同的更改):

git checkout 716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field
git reset --hard origin/716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field
chmod 755 scripts/wait-for-it.sh
git add scripts/wait-for-it.sh
git push origin 716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field

一切都进行到最后一步(推送)。如果我在推送之前执行git status,我会得到:

On branch 716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field
Your branch is up to date with 'origin/716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   scripts/wait-for-it.sh

推送给了我“一切都是最新的”消息。推送后,git status 告诉我一模一样,scripts/wait-for-it.sh 被修改;并且该文件尚未在源上更新。

我试过设置git config core.fileMode true

我也尝试通过git update-index --chmod=+x scripts/wait-for-it.sh更改文件模式。

git config -l 给出:

user.email=**myemail**
user.name=Ben Whitmore
core.autocrlf=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://gitlab.coko.foundation/kotahi/kotahi.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
branch.716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field.remote=origin
branch.716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field.merge=refs/heads/716-confirmation-modal-dialog-when-deleting-a-form-or-a-form-field

我该如何解决这个问题,还是我必须废弃分支并重新开始?

【问题讨论】:

  • git add 将其添加到 repo 并在索引中列出,但您还没有提交,所以 Git 不知道它已经准备好。
  • jthill 表示:运行git addgit commit(git push

标签: git file file-permissions


【解决方案1】:

正如 jthill 所指出的,我需要在 git push 之前使用 git commit。一个愚蠢的疏忽。

【讨论】:

    猜你喜欢
    • 2014-11-19
    • 1970-01-01
    • 2015-11-12
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 2019-03-09
    • 2014-05-28
    相关资源
    最近更新 更多