在git中恢复shell脚本文件(.sh)

问题描述 投票:1回答:1

我正在一个其中包含shell脚本文件(例如a.sh)的项目。

我在Windows上克隆了仓库,并意外地运行了a.sh。然后,当我在git bash中运行git status时,得到以下信息

git status
on branch master
Changes not staged for commit:
(use "git add <file> ..." to update what will be committed)
(use "git restore <file> ..." to discard changes in working directory)
    modified: a.sh

很显然,我不希望更改此a.sh,而是按照]的提示进行操作>

git restore a.sh

但是,当我再次运行git status时,仍然得到与a.sh相同的信息。我还分阶段尝试了另一种方法,并使用git commit -am "restore sh"提交了此文件,然后尝试通过git restore head^ a.sh重置了此文件。结果仍然相同。

所以我想知道是否有任何方法可以解决此问题?

FYI,据我的同事们说,a.sh用于杀死空闲的python线程。当我git diff这个文件时,它表明

old mode 100755
new mode 100644

我对shell脚本不是很熟悉,所以不确定此信息是否有帮助。

我正在一个包含shell脚本文件(比如说a.sh)的项目中。我在Windows上克隆了仓库,并意外地运行a.sh。然后,当我在git bash中运行git status时,得到以下信息...

bash git shell
1个回答
0
投票

欢迎使用Stackoverflow。

© www.soinside.com 2019 - 2024. All rights reserved.