Config categories

stack-3.26.0
mucr 2022-09-21 17:08:49 +08:00
parent e1dfa35800
commit d95b9bc603
5 changed files with 172 additions and 19 deletions

View File

@ -1,4 +1,4 @@
baseURL = 'http://example.org/' baseURL = 'https://blog.mitsea.com/'
languageCode = 'en-us' languageCode = 'zh-cn'
title = 'My New Hugo Site' title = 'Mitsea Blog'
theme = "hugo-theme-stack" theme = "hugo-theme-stack"

View File

@ -0,0 +1,9 @@
---
title: "苹果生态"
description: "果粉一枚"
slug: "apple"
image: "https://img.mitsea.com/blog/categories/apple.png?x-oss-process=style/ImageCompress"
style:
background: "#313132"
color: "#fff"
---

View File

@ -0,0 +1,9 @@
---
title: "Linux"
description: "关于 Linux 的文章"
slug: "linux"
image: "https://img.mitsea.com/blog/categories/linux.png?x-oss-process=style/ImageCompress"
style:
background: "#e95420"
color: "#fff"
---

View File

@ -0,0 +1,142 @@
+++
author = "FlintyLemming"
title = "【翻译】管理配置文件最好的方法:一个 bare git 仓库"
date = "2021-04-22"
description = ""
categories = ["Linux"]
tags = ["Windows", "Linux"]
image = "https://img.mitsea.com/blog/posts/2021/04/%E3%80%90%E7%BF%BB%E8%AF%91%E3%80%91%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%9C%80%E5%A5%BD%E7%9A%84%E6%96%B9%E6%B3%95%EF%BC%9A%E4%B8%80%E4%B8%AA%20bare%20git%20%E4%BB%93%E5%BA%93/title.jpg?x-oss-process=style/ImageCompress"
+++
原文地址:[https://www.atlassian.com/git/tutorials/dotfiles](https://www.atlassian.com/git/tutorials/dotfiles)
原标题The best way to store your dotfiles: A bare Git repository
译者注:本文的 dotfiles 原意指的是一些隐藏的目录或者文件,但由于实际需要管理的一般是配置文件。所以在翻译中我就把 dotfile 引申为 配置文件。
声明:标题有点绝对,肯定也有解决该问题的其他好方法。我只是介绍下我认为比较好的方案。
最近我在 [Hacker News](https://news.ycombinator.com/item?id=11070797) 上看了很多人关于管理他们[配置文件](https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory)的方法。用户 `StreakyCobra` 所[展示的方法](https://news.ycombinator.com/item?id=11071754)非常棒,我也打算像他一样管理配置文件。而且条件很简单,我只要事先安装好 [Git](https://www.atlassian.com/git) 即可。
对于这套方案,按照他的原话说就是:
没有用到任何额外的工具,也没有用到 symlinks只是用到了版本管理工具。你可以为不同的电脑创建不同的分支也可以在新电脑上直接获得已经保存的配置。
这个方案特别创建了用于保存配置文件的目录,并且在执行命令中均指定清楚了目录地址,所以不会对你其他的 git 操作产生影响。
## 从头开始
如果你还没有用 Git 仓库管理你的配置文件,你可以用下面的命令快速管理起来。
```bash
git init --bare $HOME/.cfg
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
config config --local status.showUntrackedFiles no
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc
```
- 第一行会创建一个 `~/.cfg` 文件夹,[Git bare 仓库](https://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/) 会把这个文件夹给管理起来。
- 然后创建一个 alias这句话的意思就是当我们在 shell 中执行 `config`,就等于执行 `/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME` ,方便特别管理这个 .cfg 文件夹。
- 因为是手动指定 `$HOME` 里的文件并上传,所以我们将 `status.showUntrackedFiles` 关闭,这样在查看仓库状态的时候,不会因为其他文件导致显示还有文件没有提交。
- 由于 alias 是 shell 命令,不能持久化,所以要想重启后还能继续使用。需要把这个 alias 命令写到你现在用的 shell 的配置文件里。(原文里用的是 bash
然后你就可以用 `config` 命令去添加、管理你的配置文件了。比如你要把 vim 和 bash 的配置文件都加到 Git 里,就像这样执行命令即可。
```bash
config status
config add .vimrc 
config commit -m "Add vimrc"
config add .bashrc
config commit -m "Add bashrc"
config push
```
当然,在执行 config push 前,需要配置下远程仓库。为了照顾 Git 新手,我这边放一下我的操作步骤
```bash
config remote add origin https://github.com/FlintyLemming/FlintyConfig.git
config branch -M main
config push -u origin main
```
![](https://img.mitsea.com/blog/posts/2021/04/%E3%80%90%E7%BF%BB%E8%AF%91%E3%80%91%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%9C%80%E5%A5%BD%E7%9A%84%E6%96%B9%E6%B3%95%EF%BC%9A%E4%B8%80%E4%B8%AA%20bare%20git%20%E4%BB%93%E5%BA%93/1.png?x-oss-process=style/ImageCompress)
### 需要确认的事情
1. 配置文件中已经包含了当前 shell 的配置文件,并且里面配置了刚才的 alias
2. 把 `.cfg` 添加到 `.gitignore` 里,这样在拉取时就不会导致递归问题
```bash
echo ".cfg" >> .gitignore
```
## 在新环境上找回你的配置
如果你已经在云端仓库保存了你的配置文件,你可以按照下面的步骤取回来:
- 把仓库里的内容下载下来:
```bash
git clone --bare <git-repo-url> $HOME/.cfg
```
- 设置 alias
```bash
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
```
- checkout 云端的配置文件到你的 `$HOME` 目录下:
```bash
config checkout
```
- 上面这步可能会报错,就像这样:
```bash
error: The following untracked working tree files would be overwritten by checkout:
.bashrc
.gitignore
Please move or remove them before you can switch branches.
Aborting
```
这是因为你的 `$HOME` 目录已经有这些文件了,发生了冲突。解决方法很简单:如果你不需要原来的文件,删掉即可;如果需要,就备份一下。这边提供一个冲突文件自动备份到特定文件夹下的方法:
```bash
mkdir -p .config-backup && \
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .config-backup/{}
```
然后重新 checkout
```bash
config checkout
```
- 同样把 `status.showUntrackedFiles` 关闭:
```bash
config config --local status.showUntrackedFiles no
```
- 大功告成,现在你可以像之前一样管理配置文件了,就像这样:
```bash
config status
config add .vimrc
config commit -m "Add vimrc"
config add .bashrc
config commit -m "Add bashrc"
config push
```
## 结语
希望这个方法能帮助你管理配置文件。我在这边也分享一下[我的配置文件仓库](https://bitbucket.org/durdn/cfg/src/master/)。别忘记关注我和我团队的 Twitter[@durdn](https://www.twitter.com/durdn) 和 [@atlassiandev](https://www.twitter.com/atlassiandev)。
译者:如果觉得不错的话,可以去 [Medium](https://mitsea.medium.com/%E7%BF%BB%E8%AF%91-%E7%AE%A1%E7%90%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%9C%80%E5%A5%BD%E7%9A%84%E6%96%B9%E6%B3%95-%E4%B8%80%E4%B8%AA-bare-git-%E4%BB%93%E5%BA%93-d2be0da4729c) 给我点个 Clap或者去 [Bilibili 专栏](https://www.bilibili.com/read/cv10982105) 投个币点个赞。

View File

@ -3,38 +3,31 @@ author = "FlintyLemming"
title = "老版本 Xcode 在新 iOS 设备上调试" title = "老版本 Xcode 在新 iOS 设备上调试"
date = "2019-10-06" date = "2019-10-06"
description = "主要就是补充 DeviceSupport" description = "主要就是补充 DeviceSupport"
categories = [ categories = ["Apple"]
"苹果生态" tags = ["Xcode", "iOS"]
] image = "https://img.mitsea.com/blog/posts/2019/10/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/title.jpg?x-oss-process=style/ImageCompress"
tags = [
"Xcode",
"iOS"
]
image = "https://img.mitsea.com/blog/posts/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/title.jpg?x-oss-process=style/ImageCompress"
+++ +++
# 老版本 Xcode 在新 iOS 设备上调试 ## 补充老版本 Xcode 缺失的 DeviceSupport
**补充老版本 Xcode 缺失的 DeviceSupport**
如果你有安装新版本的 Xcode那可以直接拷贝过来没有的话可以去这里下载 [https://github.com/filsv/iPhoneOSDeviceSupport](https://github.com/filsv/iPhoneOSDeviceSupport) 。下载完毕后,拷贝到 Xcode/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport 目录下,当然也可以加上具体的版本号,以 iOS 13.1.1 为例,文件夹名称就可以写为 如果你有安装新版本的 Xcode那可以直接拷贝过来没有的话可以去这里下载 [https://github.com/filsv/iPhoneOSDeviceSupport](https://github.com/filsv/iPhoneOSDeviceSupport) 。下载完毕后,拷贝到 Xcode/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport 目录下,当然也可以加上具体的版本号,以 iOS 13.1.1 为例,文件夹名称就可以写为
``` ```
13.1.1 (17A854) 13.1.1 (17A854)
``` ```
![](https://img.mitsea.com/blog/posts/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/1.jpg) ![](https://img.mitsea.com/blog/posts/2019/10/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/1.jpg?x-oss-process=style/ImageCompress)
其实补充 DeviceSupport 就可以解决一部分一个大版本内无法调试的情况。如果跨大版本,请继续下面的操作 其实补充 DeviceSupport 就可以解决一部分一个大版本内无法调试的情况。如果跨大版本,请继续下面的操作
**修改 SDK 文件信息** ## 修改 SDK 文件信息
在 Xcode/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs 目录下,复制一份现有的 sdk 文件,并修改为需要的版本,比如我这里就修改为 iPhoneOS13.1.1.sdk 在 Xcode/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs 目录下,复制一份现有的 sdk 文件,并修改为需要的版本,比如我这里就修改为 iPhoneOS13.1.1.sdk
![](https://img.mitsea.com/blog/posts/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/2.jpg) ![](https://img.mitsea.com/blog/posts/2019/10/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/2.jpg?x-oss-process=style/ImageCompress)
然后 修改 iPhoneOS.sdk 里(不是 iPhoneOS13.1.1.sdk的 SDKSettings.plist 文件。将原来的版本信息全部改成你需要的,比如我这里都改成 13.1.1。当然那个 DefaultDeploymentTarget 仍然可以按照原来的格式改成 13.1.99。改完保存,可能关闭按钮上显示没有保存,但其实是保存了的。如果不能保存,把文件拖到别的地方,改好后再覆盖回去。 然后 修改 iPhoneOS.sdk 里(不是 iPhoneOS13.1.1.sdk的 SDKSettings.plist 文件。将原来的版本信息全部改成你需要的,比如我这里都改成 13.1.1。当然那个 DefaultDeploymentTarget 仍然可以按照原来的格式改成 13.1.99。改完保存,可能关闭按钮上显示没有保存,但其实是保存了的。如果不能保存,把文件拖到别的地方,改好后再覆盖回去。
![](https://img.mitsea.com/blog/posts/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/3.jpg) ![](https://img.mitsea.com/blog/posts/2019/10/%E8%80%81%E7%89%88%E6%9C%AC%20Xcode%20%E5%9C%A8%E6%96%B0%20iOS%20%E8%AE%BE%E5%A4%87%E4%B8%8A%E8%B0%83%E8%AF%95/3.jpg?x-oss-process=style/ImageCompress)
**重启 Xcode** ## 重启 Xcode
一定要重启,不然不会生效 一定要重启,不然不会生效