Skip to content

Instantly share code, notes, and snippets.

@makhnanov
Last active March 1, 2024 13:41
Show Gist options
  • Save makhnanov/275672ed5d139170d62d338ddf18faab to your computer and use it in GitHub Desktop.
Save makhnanov/275672ed5d139170d62d338ddf18faab to your computer and use it in GitHub Desktop.
How to change permission for not changed files in git
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