Skip to content

Instantly share code, notes, and snippets.

@by-sknight
Last active October 30, 2024 02:40
Show Gist options
  • Save by-sknight/df7538a6f23c24f2732d7be5acfb05d1 to your computer and use it in GitHub Desktop.
Save by-sknight/df7538a6f23c24f2732d7be5acfb05d1 to your computer and use it in GitHub Desktop.
github repo sync to xylink

github sync to xylink

描述

将所有的非项目代码都保存在一个地方,是一个不错的想法,比如说常用的各种脚本,一个保存在 github,另一个保存在 gitlab, 找的时候就需要花费更多的时间,而且有的时候,还需要保存在公司自建的代码仓库中,使用特定的vpn去访问

分散在各处很难互相同步,导致查找的效率也很低,因此,希望这个 gist 能够提供一个快速同步的方法,从而在自己的电脑上(同时可以访问多个环境) 能够快速的完成同步工作,这样只需要考虑优先在哪个平台开发,之后一键同步到其他平台就可以了

当前状态

初始化脚本正常可用,同步脚本在同步过程中会报一些特殊分支的同步错误,不过不影响正常分支的同步

#!/bin/bash
# 配置仓库信息
repo_name=""
github_url=""
xylink_url=""
# 清理存在的仓库目录
if [ -d "${repo_name}.git" ]; then
echo "==== remove existing ${repo_name}.git ===="
rm -rf ${repo_name}.git
fi
# 克隆仓库
echo "==== clone ${repo_name}.git using ${github_url} ===="
git clone --mirror ${github_url}
cd ${repo_name}.git
# 配置远端仓库
git remote add github ${github_url}
git remote add xylink ${xylink_url}
# 拉取所有lfs文件
echo "==== fetch lfs files ===="
git lfs fetch --all
# 推送到新仓库
echo "==== push to xylink using ${xylink_url} ===="
git lfs push --all xylink
git push --mirror xylink
echo "done"
#!/bin/bash
# 使用方式,进入目标mirror仓库,调用 ../quick_sync.sh
# 拉取更新
echo "==== fetch from github ===="
git fetch
git lfs fetch --all
# 推送到新仓库
echo "==== push to xylink ===="
git lfs push --all xylink
git push --mirror xylink.git
#!/bin/bash
# 配置仓库信息
repo_name=""
# 进入仓库目录
cd ${repo_name}
# 拉取更新
echo "==== fetch from github ===="
git fetch
git lfs fetch --all
# 推送到新仓库
echo "==== push to xylink ===="
git lfs push --all xylink
git push --mirror xylink.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment