惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Cloudbric
Cloudbric
I
InfoQ
V
V2EX
博客园_首页
The Register - Security
The Register - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Secure Thoughts
Vercel News
Vercel News
Forbes - Security
Forbes - Security
云风的 BLOG
云风的 BLOG
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
D
DataBreaches.Net
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
A
About on SuperTechFans
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
Help Net Security
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
N
Netflix TechBlog - Medium
Spread Privacy
Spread Privacy
F
Full Disclosure
Recorded Future
Recorded Future
AWS News Blog
AWS News Blog
博客园 - 【当耐特】
The Cloudflare Blog
T
Threatpost
T
Tor Project blog
Google DeepMind News
Google DeepMind News
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
A
Arctic Wolf
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
Cyberwarzone
Cyberwarzone
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Security Latest
Security Latest
The Last Watchdog
The Last Watchdog

技术教程 – 魔帆博客

Mac mini + iPad 随航梦幻联动!零显示器配置指南,iPad 秒变 Mac 主屏幕 | 魔帆博客 使用 GNU/Linux 搭建多出口软路由 | 魔帆博客 配置和使用 Windows Dev Drive 开发驱动器 | 魔帆博客 解锁iOS侧载自由:使用sideStore轻松搞定ipa签名 | 魔帆博客 Git配置:如何优雅的配置多用户并使用 ssh 密钥验证 | 魔帆博客 Windows 注册表编辑或清除多显示器配置 | 魔帆博客 Linux 报错Certificate verification failed: The certificate is NOT trusted. | 魔帆博客 安装有 RootMagiskXposedPlay 的 WSA 安卓子系统 | 魔帆博客 Fedora 系统升级 32->34 跨版本升级 | 魔帆博客 教程:如何更新安装 docker-compose V2 和使用 docker switch | 魔帆博客 Windows10 系统盘开启 Bitlocker | 魔帆博客 2022 年 Android 下的安卓浏览器使用指北-Firefox向 | 魔帆博客 Docker WSL1/2 迁移 Linux 发行版目录 | 魔帆博客 Spotify 主题 spicetify-fluent - 微软 win11 风格美化 | 魔帆博客 WSA 安卓子系统 adb 提示 cannot connect the target machine actively refused it 10061 | 魔帆博客 双重验证 Authy 导出所有 TOTP token 和 golang 配置 GOPROXY 解决网络问题 | 魔帆博客 powershll 像 bash 一样为单个命令设置临时环境变量 | 魔帆博客 Linux 教程:Linux 初学者必了解的概念 | 魔帆博客 安卓电池充电保护-智能充电/温控切断(Root方案) | 魔帆博客
Git 提示 fatal: unsafe repository is owned by someone else 错误 | 魔帆博客
野小新 · 2022-04-26 · via 技术教程 – 魔帆博客

最近在使用 Git 和 GitHub Actions 时,应该不少人都遇到了这个问题:

fatal: unsafe repository ('D:/Paxos/scoop/buckets/MorFans' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory D:/Paxos/scoop/buckets/MorFans

解决

这个问题可能和 Git安全漏洞公布| GitHub 博客 有关,应该只发生于最近更新的 git 程序

解决方案也很简单,因为这个报错是因为当前目录所有者不是当前操作系统的用户。

下面介绍两种方法解决这个问题:

  1. 修改文件所有者
  2. 添加安全目录

修改文件所有者

Windows 修改所有者方法

如果习惯使用命令行,可以使用 takeown.exe 快速设定所有者为当前用户:

takeown.exe /F .\nonportable /R

命令行批量处理:

Get-ChildItem -Directory | % {takeown.exe /F $_ /R }

或者使用图形界面修改:

找到 git repo 的文件夹,右键点击属性:

3967533be19f476f98ee2daa3bcf6240
右键进入git repo 的文件夹属性

找到 安全,点击高级设置:

dae9ee6aa2434f24bca2b0c9ff527712
进入权限设置

在弹出的窗口点击更改,输入自己电脑的用户名:

f5c49d88abbe4883a4d01d15c4940586
修改当前所有者用户
9e1514d625354a8480b32507626db4b3
按照图示操作然后应用设置

Linux 等Unix系系统修改所有者方法

# paxos:morfans => 用户名:组
sudo chown -R paxos:morfans  gitRepo文件夹路径

还可以通过指定 git 的用户身份运行

假设 morfans 是存储库所有者

sudo -u morfans -- git status

添加 git 安全目录

第二个方法就是 git 命令报错时候提示的方法。

如果你是在 GitHub Actions 中遇到这个问题,可能添加 safe.directory 是更方便的选择。

让 git 信任这个目录(如果您知道目录内容是安全的)

git config --global --add safe.directory <Git Repo文件夹路径>

或者手动调整 git 配置文件 C:\Users\<username>\.gitconfig

[safe]
    directory = gitRepo文件夹路径

repo太多了,批量来

Linux 下可以使用 find 命令来批量执行:

如果子目录太多了,可以使用 -maxdepth 参数

find 完整路径 -name '.git' -type d -exec bash -c 'git config --global --add safe.directory ${0%/.git}' {} \;

Windows 下可以使用 powershell 批量执行:

(ls D:\PowerShell\ParentFolder\ -Directory).FullName -replace '\\','/' | %{git config --global --add safe.directory $_}

虽然但是 👀,还是推荐修改文件夹权限,而不是添加 安全文件夹