The primary purpose of Git is to keep a history of changes, or revisions. To illustrate this, let's create a simple file and commit it to the history of the repository.
First, let's confirm our repository's Git history by running git log
, which shows a history of past commits:
$ git log fatal: your current branch 'master' does not have any commits yet
The error correctly informs us that there are currently no commits. Now, let's create a short README.md
file, which represents the first change we want to commit:
$ cd ~/projects/hobnob/ $ echo -e "# hobnob" >> README.md
We've created our first file and thus made our first change. We can now run git status
, which will output information about the current state of our repository. We should see our README.md
file being picked up by Git:
$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) README.md nothing added to commit but...