DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: forget66
今日帖子: 62
在线用户: 13
导航: 论坛 -> 发布代码 斑竹:liumazi,ruralboy  
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2022/7/12 18:06:32
标题:
bash 模仿go get 把github 都拉到一个目录 浏览:1159
加入我的收藏
楼主: gitco 内容

#!/bin/sh
#输入 gitco https://github.com/piscisaureus/wepoll.git ; 最好不要复制带.git 直接复制url
dest_mydir="/home/make/.local/bin/lstest/" #存放路径
str=${1}          #https://github.com/piscisaureus/wepoll.git
githubpname=${str##*/}  #wepoll.git
githubp=${str%/*}       #https://github.com/piscisaureus
github=${githubp#*://}  #github.com/piscisaureus
githuburl=${github%/*}  #github.com 
githubpurl=${github#*/} #piscisaureus
DEST_DIR=${dest_mydir}${githuburl}
if [ ! -d "$DEST_DIR" ]; then
    mkdir -p "$DEST_DIR"
fi
# 切换工作目录至 /home/make/.local/bin/lstest
cd "$DEST_DIR" || { echo -e "\033[31m文件不存在\033[0m"; exit 1; } #输出(红)彩色文本
https://blog.csdn.net/qualcent/article/details/7106483 ;echo颜色表
work=${DEST_DIR}"/"${githubpname}
git clone --recurse-submodules ${str} ${work}
cd ${work}
git pull --all


还有更妙的写法吗?。。
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/7/13 2:58:34
1楼: Bash script to get the current git branch and last commit
----------
git_branch.sh
#!/usr/bin/env bash

# checks if branch has something pending
function parse_git_dirty() {
  git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}

# gets the current git branch
function parse_git_branch() {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}

# get last commit hash prepended with @ (i.e. @8a323d0)
function parse_git_hash() {
  git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/@\1/"
}

# DEMO
GIT_BRANCH=$(parse_git_branch)$(parse_git_hash)
echo ${GIT_BRANCH}

----------
Shell Script To Cleanup Merged Git Branches
----------
git-branch-cleanup.sh
# This has to be run from master
git checkout master

# Update our list of remotes
git fetch
git remote prune origin

# Remove local fully merged branches
git branch --merged master | grep -v 'master$' | xargs git branch -d

# Show remote fully merged branches
echo "The following remote branches are fully merged and will be removed:"
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$'

read -p "Continue (y/n)? "
if [ "$REPLY" == "y" ]
then
   # Remove remote fully merged branches
   git branch -r --merged master | sed 's/ *origin\///' \
          | grep -v 'master$' | xargs -I% git push origin :%
   echo "Done!"
   say "Obsolete branches are removed"
fi

#This scirpt doesn't work if you have multiple remotes. Piping the output of git branch -r --merged master both times that it's run into grep ' *origin/' before piping it through the sed fixes it.

----------
many script for you!
https://gist.github.com/dciccale
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行62.5毫秒 RSS