This action will force synchronization from turnon/java-tutorial, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#!/usr/bin/env bash## 检查脚本参数,如必要参数未传入,退出脚本。#checkInput() {if [ "${repository}" == "" ] || [ "${branch}" == "" ]; thenecho "请输入脚本参数:repository branch [source] [target]"echo " repository: git 仓储(必填)。"echo " branch: git 分支(必填)。如 master/develop"echo " source: 代码存放目录。默认为/home/zp/source。"echo " target: 代码存放目录。默认为脚本所在目录。"exit 0fi}## 判断 git 版本库是否存在。根据实际结果修改 ${gitok} 值。#gitok=falseisGitExist() {cd ${SOURCE_PATH}if [ -d "${SOURCE_PATH}/${repository}/${target}" ]; thencd ${SOURCE_PATH}/${repository}/${target}#(1)删除git状态零时文件if [ -f "gitstatus.tmp" ]; thenrm -rf gitstatus.tmpfi#(2) 判断是否存在.git目录if [ -d "./.git" ]; then#(3) 判断git是否可用git status &> gitstatus.tmpgrep -iwq 'not a git repository' gitstatus.tmp && gitok=false || gitok=truefi#返回到主目录cd ${SOURCE_PATH}fi}## 如果 git 版本库存在(根据 ${gitok} 值),执行 fetch 操作;反之,执行 clone 操作。#doFetchOrClone() {if [ ! -d "${SOURCE_PATH}" ]; thenmkdir -p ${SOURCE_PATH}fiif ${gitok}; thencd ${SOURCE_PATH}/${repository}/${target}git reset --hardgit clean -ffdxgit fetchecho "git fetch ${repository} remote repository 到本地成功"else#删除所有内容,便于重新进行git clonerm -rf ${repository}git clone --no-checkout git@github.com:${ACCOUNT}/${repository}.git ${SOURCE_PATH}/${repository}/${target}echo "git clone ${repository} remote repository 到本地成功"cd ${SOURCE_PATH}/${repository}/${target}fi}## 切换到 ${branch} 分支#doCheckout() {echo "检出 ${repository}${branch} 分支代码"isRemoteBranch=falsegitRemoteBranch=`git branch -r`echo -e "$gitRemoteBranch" | grep -iwq ${branch} && isRemoteBranch=true || isRemoteBranch=falseif ${isRemoteBranch}; thenecho "找到 ${branch} 对应的远端分支"git checkout -f 'origin/'${branch}elsegit checkout -f ${branch}fiecho "更新子模块代码"git submodule update --init --recursive --force}##############################__MAIN__########################################export LANG="zh_CN.UTF-8"# Github 账户ACCOUNT=dunwu# 源码默认根目录SOURCE_PATH=/home/zp/source# 必填输入参数repository=`echo 1ドル`branch=`echo 2ドル`# 可选输入参数source=`echo 3ドル`target=`echo 4ドル`if [ "${source}" != "" ]; thenSOURCE_PATH=${source}fi# 0. 检查传入的参数checkInput# 1. 判断本地是否已存在 Git 仓库isGitExist# 2. 如果本地已有代码,执行 fetch;反之,从远程 clonedoFetchOrClone# 3. 切换到指定分支doCheckoutecho "代码检出完成!"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。