Created
January 14, 2026 18:49
-
-
Save disouzam/1ddef9c33f3704fcc873f7d868d742de to your computer and use it in GitHub Desktop.
Script to use for tutorial purposes on 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
| #!/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" |
Author
Author
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
Usage:
Side effect: two text files in your repo (
files-in-git.txtandfiles-in-git_old.txt).Script can be edited to add these files to .gitignore