#!/bin/bash
# Ensure we're inside a git repo
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "Not a git repository."
exit 1
fi
# Basic info
TOP=$(git rev-parse --show-toplevel)
REPO_NAME=$(basename "$TOP")
CURRENT_BRANCH=$(git branch --show-current)
REMOTE_URL=$(git remote get-url origin 2>/dev/null)
# Parse Bitbucket owner + repo
if [[ "$REMOTE_URL" =~ bitbucket\.org/([^/]+)/([^\.]+) ]]; then
BB_OWNER="${BASH_REMATCH[1]}"
BB_REPO="${BASH_REMATCH[2]}"
else
BB_OWNER="N/A"
BB_REPO="N/A"
fi
# Default remote branch
DEFAULT_REMOTE=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's#^.*/##')
# Remote branches
REMOTE_BRANCHES=$(git ls-remote --heads origin 2>/dev/null | awk '{print $2}' | sed 's#refs/heads/##')
# Remote tags
REMOTE_TAGS=$(git ls-remote --tags origin 2>/dev/null | awk '{print $2}' | sed 's#refs/tags/##')
echo ""
echo "===== Git / Bitbucket Repo Info ====="
echo "Local repo name: $REPO_NAME"
echo "Local path: $TOP"
echo "Current branch: $CURRENT_BRANCH"
echo "Remote URL: $REMOTE_URL"
echo "Bitbucket team: $BB_OWNER"
echo "Bitbucket repo: $BB_REPO"
echo "Default branch: ${DEFAULT_REMOTE:-N/A}"
echo ""
echo "---- Remote Branches ----"
echo "$REMOTE_BRANCHES"
echo ""
echo "---- Remote Tags ----"
echo "$REMOTE_TAGS"
echo "======================================"
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)