跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[分享创造] 一个备份 git 仓库的思路,各位有什么建议

发表于
git config alias.backup '!f() { ([ -f "/path/to/git-backup/$1/HEAD" ] || git init --bare "/path/to/git-backup/$1") && (git remote set-url --delete origin "/path/to/git-backup/$1" 2>/dev/null; git remote set-url --add origin "/path/to/git-backup/$1"); }; f'

cd /path/to/something

git init
git remote add origin git@github.com:username/something.git

git backup something

git remote -v
# origin	git@github.com:username/something.git (fetch)
# origin	git@github.com:username/something.git (push)
# origin	/path/to/git-backup/something (push)

如此在每次 push 到 github/gitlab 的同时,还会 push 到 /path/to/git-backup 下,然后再用备份工具对 /path/to/git-backup 进行备份,这样:

  1. 不用考虑排除哪些文件,不挑备份工具,备份脚本不复杂
  2. 不用考虑用的是什么 git hosting service
  3. 不需要额外运行个服务(本来是打算跑个 gitea/gogs 的,但是为了可以加密备份放弃了)

未解决:

  1. 并非本地做的一些变更提交,例如 actions 中产生的
  2. 未提交的变更,其实我并没有这个需求,我认为只对提交负责挺好的
  3. 代码以外的东西,例如 issues 、pull requests 、discussions 中的讨论,尽管我没有这个需求
  4. .gitignore 排除掉的秘密、配置文件,虽然以前提问过,站内有人推荐 git-crypt ,但我觉得我还需要一个别的方案

各位对此思路有什么想法和建议吗?

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.