Created
March 20, 2026 09:17
-
-
Save jesobreira/b07e10a7aae75fa5da3c71197c67c7be to your computer and use it in GitHub Desktop.
Git Preview Pull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git config --global alias.preview-pull '!f() { | |
| BRANCH=$(git rev-parse --abbrev-ref HEAD); | |
| REMOTE=${1:-origin}; | |
| echo "🔎 Fetching $REMOTE..."; | |
| git fetch $REMOTE || return; | |
| echo ""; | |
| echo "📌 Branch atual: $BRANCH"; | |
| echo "📌 Comparando com: $REMOTE/$BRANCH"; | |
| echo ""; | |
| echo "🧠 Tipo de atualização:"; | |
| LOCAL=$(git rev-parse HEAD); | |
| REMOTE_HEAD=$(git rev-parse $REMOTE/$BRANCH); | |
| BASE=$(git merge-base HEAD $REMOTE/$BRANCH); | |
| if [ "$LOCAL" = "$REMOTE_HEAD" ]; then | |
| echo "✔ Já está atualizado"; | |
| elif [ "$LOCAL" = "$BASE" ]; then | |
| echo "⬆️ Fast-forward (seguro)"; | |
| elif [ "$REMOTE_HEAD" = "$BASE" ]; then | |
| echo "⚠️ Você está à frente (push pendente)"; | |
| else | |
| echo "🔥 Vai dar MERGE (histórico divergiu)"; | |
| fi | |
| echo ""; | |
| echo "📝 Commits que vão entrar:"; | |
| git log --oneline HEAD..$REMOTE/$BRANCH; | |
| echo ""; | |
| echo "📂 Arquivos que vão mudar:"; | |
| git diff --name-status HEAD $REMOTE/$BRANCH; | |
| echo ""; | |
| echo "📊 Resumo:"; | |
| git diff --stat HEAD $REMOTE/$BRANCH; | |
| }; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment