Created
May 21, 2018 03:54
-
-
Save berlotto/66c2380a1d352fb8db7b325961585817 to your computer and use it in GitHub Desktop.
Reseta arquivos que não tem diferença de alteração de linhas no git
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
# Este script basea-se no número de alterações ocorridas no arquivo para, se for ZERO, fazer um 'git checkout <filename>' | |
# Isto foi necessário pois fiz uma cópia do repositório de um HD antigo para o novo e quando executei 'git status' apareceram TODOS os arquivos como diferença | |
# então precisei saber quais realmente continham diferenças. | |
# Execute-o na base do seu reposório git. | |
# LICENSE: MIT | |
# Author: Sérgio Berlotto <[email protected]> | |
FILES=`git diff --name-only` | |
regex='^([1-9]*).+/' | |
while IFS=';' read -ra ADDR; do | |
for i in "${ADDR[@]}"; do | |
STAT=`git diff --stat $i | head -n 1 | cut -d '|' -f2 | tr -d '[:space:]'` | |
if [ "$STAT" == "Bin" ] || [ "$STAT" == "0" ]; then | |
git checkout "$i" | |
fi | |
done | |
done <<< "$FILES" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment