#!/bin/bash #paras: $1 dir #config section USER=Shawn REMOTE_PATH="~/path/${USER}/${1}" ###################### function current_branch() { git rev-parse --abbrev-ref HEAD | grep -v HEAD || \ git describe --tags HEAD || \ git rev-parse HEAD } cd $1 CURRENT_BRANCH=$(current_branch) LOCAL_PATH=$(pwd) git fetch origin #git pull origin development ssh root@${IP_ADDR_DST} " \ mkdir -p ${REMOTE_PATH}; \ cd ${REMOTE_PATH}; \ git init; \ git remote add origin ${USER}@${IP_ADDR_SRC}:${LOCAL_PATH}; \ git remote set-url --add origin ${USER}@${IP_ADDR}:${LOCAL_PATH}; \ git fetch origin; \ git checkout -b ${CURRENT_BRANCH} origin/${CURRENT_BRANCH}; \ git pull origin${CURRENT_BRANCH}; \
标签:origin,HEAD,git,拉取,CURRENT,shell,USER,PATH From: https://www.cnblogs.com/tju1895/p/16647239.html