reposync

repo forall -pvc git stash | tee

repo forall -pvc git checkout | tee

repo forall -pvc git reset --hard HEAD | tee

repo forall -pvc git clean -dfx | tee

使用 | tee是为了避免分屏导致的输出暂停

注意这个操作会导致本地未commit的或者commit了但是没建分支的代码丢失

 

使用下面的命令sync

repo sync -c -d --force-sync --force-broken --no-tags

-c 的意思是只下载manifest中定义的当前分支,不下载其他分支,manifest中默认会开启 -c

-d 的意思脱离本地分支,切换到服务器的分支,前提是本地代码要clean

--no-tags 不下载 tag,可以减少时间,节省空间,一般情况下我们也用不到tag

 

#!/bin/bash


color_black_on="printf \033[30m"
color_red_on="printf \033[31m"
color_green_on="printf \033[32m"
color_yellow_on="printf \033[33m"
color_blue_on="printf \033[34m"
color_purple_on="printf \033[35m"
color_cyan_on="printf \033[36m"
color_white_on="printf \033[37m"

color_off="printf \033[0m"


date
start_time0=`date +%s`
echo ""

$color_red_on
ls -l .repo/manifest.xml
$color_off
echo ""

$color_yellow_on
ls -l .repo/manifest.xml
$color_off
echo ""

$color_cyan_on
ls -l .repo/manifest.xml
$color_off
echo ""


#------------------------------------------


$color_green_on
echo "repo forall -pvc git stash"
$color_off
start_time=`date +%s`
repo forall -pvc git stash | tee
time=$((`date +%s` - start_time))
$color_green_on
printf "git stash end, time: %02d:%02d:%02d\n\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off

$color_green_on
echo "repo forall -pvc git checkout"
$color_off
start_time=`date +%s`
repo forall -pvc git checkout | tee
time=$((`date +%s` - start_time))
$color_green_on
printf "git checkout end, time: %02d:%02d:%02d\n\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off

$color_green_on
echo "repo forall -pvc git reset --hard HEAD"
$color_off
start_time=`date +%s`
repo forall -pvc git reset --hard HEAD | tee
time=$((`date +%s` - start_time))
$color_green_on
printf "git reset end, time: %02d:%02d:%02d\n\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off

$color_green_on
echo "repo forall -pvc git clean -dfx"
$color_off
start_time=`date +%s`
repo forall -pvc git clean -dfx | tee
time=$((`date +%s` - start_time))
$color_green_on
printf "git clean end, time: %02d:%02d:%02d\n\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off

$color_green_on
echo "repo sync -c -d --force-sync --force-broken --no-tags"
$color_off
start_time=`date +%s`
repo sync -c -d --no-tags
time=$((`date +%s` - start_time))
$color_green_on
printf "repo sync end, time: %02d:%02d:%02d\n\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off


date
time=$((`date +%s` - start_time0))
$color_green_on
printf "Total time: %02d:%02d:%02d\n" $((time/3600)) $((time%3600/60)) $((time%60))
$color_off

上一篇:PAT 1026.程序运行时间


下一篇:【dp每日一题】HDU 1260 Tickets