Skip to content

Instantly share code, notes, and snippets.

@halityurttas
Last active July 21, 2025 23:06
Show Gist options
  • Select an option

  • Save halityurttas/dd27f6de045c0b6759dd62f54a042491 to your computer and use it in GitHub Desktop.

Select an option

Save halityurttas/dd27f6de045c0b6759dd62f54a042491 to your computer and use it in GitHub Desktop.
Path copy with hierarcy
#!/bin/bash
# Hedef dizin
hedef_dizin="C:/Depo/gitbackup"
# Git'te modify edilmiş ve untracked dosyaları al
modified_files=$(git diff --name-only)
untracked_files=$(git ls-files --others --exclude-standard)
# Tüm değişiklikleri birleştir
all_files="$modified_files $untracked_files"
# Her dosya için işlem yap
for file in $all_files; do
if [ -f "$file" ]; then # Sadece dosyaları işle
# Hedef dizini oluştur (eğer yoksa)
mkdir -p "$hedef_dizin/$(dirname "$file")"
# Dosyayı kopyala
cp "./$file" "$hedef_dizin/$file"
echo "$file kopyalandı"
fi
done
echo "Tüm değiştirilmiş ve takip edilmeyen dosyalar başarıyla kopyalandı!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment