X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/bd4ff344cc3dcaefca30e4ebdca956cd3d92b3b2..e67680074e04e0eaea680de93133327162d73304:/unitproc/bktemp-initGitRepo?ds=sidebyside diff --git a/unitproc/bktemp-initGitRepo b/unitproc/bktemp-initGitRepo index 4575daf..10cfe40 100644 --- a/unitproc/bktemp-initGitRepo +++ b/unitproc/bktemp-initGitRepo @@ -31,11 +31,15 @@ initGitRepo() { # arg2: repoDir # arg3: remoteName # arg4: branchName - # Version: 0.0.6 + # Version: 0.0.9 # Depends: checkURL() 0.0.2, yell(), Bash 5.0.3 # Ref/Attrib: [1]: Test for space-less alphanuemric string. https://unix.stackexchange.com/a/416120 # [2]: Test for argument count. https://stackoverflow.com/q/18568706 # [3]: Test if dir is (in) git repository. https://stackoverflow.com/a/39518382 + # Note: Pulls use '--ff-only' option which requires an upstream branch be set. + # This can be done by using: + # $ git branch --set-upstream-to origin/master master + # #==BEGIN Validate input arguments== arg1="$1"; arg2="$2"; @@ -71,8 +75,10 @@ initGitRepo() { fi; yell "STATUS:Adding $repoURL as remote $remoteName"; git remote add "$remoteName" "$repoURL"; + git branch --set-upstream-to "$remoteName"/"$branchName" "$branchName"; yell "STATUS:Pulling branch $branchName from remote $remoteName"; - git pull "$remoteName" "$branchName"; + git pull --ff-only "$remoteName" "$branchName"; + git fetch "$remoteName"; unset repoURL repoDir remoteName branchName; popd || exit 1; #==END create and populate git repository==