Git Ignore & Git Log

I tackled some of the basics of Git / Git Hub in my previous blog post. Today I am going to look at Ignoring and Logging.

Git Log

Navigate to a folder that is git repository and run the command:

git log

This command should make the terminal output the history (i.e. all the changes) of the repository, include commit references.

Git log example
Git log example

The commit reference is actually a unique hash that references the repository and the changes made. The author is the person that made the changes. The date is the date and time of the changes and the modified is the file that was changed (or created). The log will contain an “initial commit” to show the first (initial commit) change made.

Git Ignore

The Git ignore file is (as the name suggests) a file that tells Git what to ignore when committing the repository. Placed at the 1st level of the repository’s folder structure the file should be called .gitignore (Note the . at the beginning of the file name).

Within the .gitignore file can be any files, file types or sub-folders that you want Git to ignore. For example, when creating and testing Python programs a cache folder stores temporary details about the program called __pycache__. This is probably something you would not want to copy back to a repository or share. The __pycache__ folder can be added to .gitignore and then Git ignores it. The .gitignore file itself ignores any contents within itself that are blank lines or lines starting with # (which it sees as comments).

geektechstuff_git_gitignore
Example .gitignore file