diff --git a/bdt.sh b/bdt.sh index a187043..380ba96 100755 --- a/bdt.sh +++ b/bdt.sh @@ -2232,9 +2232,29 @@ cmd_self_update() { ( cd "$cli_dir" || exit 1 local remote="origin" - git fetch "$remote" "$branch" 2>/dev/null || true - git pull --ff-only "$remote" "$branch" 2>/dev/null || git pull --ff-only "$remote" main - ) || { err "git pull falló en ${cli_dir}"; return 1; } + git fetch "$remote" "$branch" || git fetch "$remote" + + # Repo sembrado con git init local (master sin commits) → alinear con origin/main + local cur_branch + cur_branch="$(git branch --show-current 2>/dev/null || echo "")" + if [[ -z "$cur_branch" || "$cur_branch" == "master" ]] \ + && git show-ref --verify --quiet "refs/remotes/${remote}/${branch}"; then + git checkout -B "$branch" "${remote}/${branch}" + fi + + git branch --set-upstream-to="${remote}/${branch}" "$branch" 2>/dev/null \ + || git branch --set-upstream-to="${remote}/${branch}" main 2>/dev/null \ + || true + + git pull --ff-only "$remote" "$branch" + ) || { + err "git pull falló en ${cli_dir}" + echo -e " ${GRAY}Probá manualmente:${NC}" + echo -e " ${GRAY} cd ${cli_dir} && git fetch origin && git checkout -B main origin/main${NC}" + echo -e " ${GRAY} git branch --set-upstream-to=origin/main main && git pull${NC}" + echo -e " ${GRAY}Si pide usuario/clave: bdt git-auth ${NC}" + return 1 + } ok "Repo actualizado" fi