Last active
March 1, 2024 13:41
-
-
Save makhnanov/275672ed5d139170d62d338ddf18faab to your computer and use it in GitHub Desktop.
How to change permission for not changed files in 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
echo "Enter your slave branch:" | |
read your_branch | |
echo "Enter your main branch:" | |
read master_branch | |
changes=$(git --no-pager diff --name-only "$master_branch" "$your_branch") | |
while IFS= read -r file; | |
do | |
file_changes=$(git --no-pager diff "$master_branch" "$your_branch" -- "$file") | |
line_count=$(echo "$file_changes" | wc -l) | |
if [ "$line_count" -eq 3 ]; then | |
line2=$(echo "$file_changes" | sed -n '2p') # Get the second line | |
line3=$(echo "$file_changes" | sed -n '3p') # Get the third line | |
if [[ "$line2" == "old mode"* ]] && [[ "$line3" == "new mode"* ]]; then | |
chmod -x "$file" | |
fi | |
fi | |
done <<< "$changes" | |
echo "Success! Happy codding!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment