Skip to content

Instantly share code, notes, and snippets.

@disouzam
Created January 14, 2026 18:49
Show Gist options
  • Select an option

  • Save disouzam/1ddef9c33f3704fcc873f7d868d742de to your computer and use it in GitHub Desktop.

Select an option

Save disouzam/1ddef9c33f3704fcc873f7d868d742de to your computer and use it in GitHub Desktop.
Script to use for tutorial purposes on Git
#!/bin/bash
# A script to inspect the current Git repository status and display relevant information.
file_name="files-in-git"
old_file="${file_name}_old.txt"
new_file="${file_name}.txt"
function generate_git_file_list() {
ls -1 -R .git > $1
}
if [ -f "$new_file" ] && [ ! -f "$old_file" ]; then
mv "$new_file" "$old_file"
echo "File renamed from $new_file to $old_file"
elif [ ! -f "$new_file" ]; then
echo "File $new_file does not exist"
generate_git_file_list "$old_file"
fi
generate_git_file_list "$new_file"
git diff --no-index "$old_file" "$new_file"
@disouzam
Copy link
Author

disouzam commented Jan 14, 2026

Inspired on John Britton's presentation at https://www.youtube.com/watch?v=lG90LZotrpo&t=7s, entitled
Git Internals by John Britton of GitHub - CS50 Tech Talk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment