Skip to content

Commit

Permalink
annotations and question answers
Browse files Browse the repository at this point in the history
  • Loading branch information
brownsarahm committed Sep 30, 2023
1 parent f6e3ddc commit b3885c6
Show file tree
Hide file tree
Showing 2 changed files with 429 additions and 214 deletions.
165 changes: 160 additions & 5 deletions notes/2023-09-26.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,168 @@
# What is a commit?

```{warning}
Due to events beyond my control the full details for today's class will be posted late. In the short term, if you missed class, attend office hours and use the prismia to make up the key steps.
Due to events beyond my control the full details for this class were lost. Below contains all of the notes and explanation, but not every command that was run and the actual output at each step.
No notes yet because I made an error and did not save my terminal output from the codespace before I left the classroom.
To produce the notes, I will have to use the commit history and the prismia log to re-do the activity in a copy of my repo that I manipulate to undo things so that I can recreate.
```


## Housekeeping

### In class time

reminder: you are expected to follow along with what I model in my terminal and use prismia as a backup if you miss something or get an error.



### Notifications

reminder: I post announcements as [releases](https://github.com/introcompsys/fall2023/releases)

To get notified, [watch the repo](https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/configuring-notifications#configuring-your-watch-settings-for-an-individual-repository).


### Penalty free zone is over.

- all past badges can be submitted at any time
- all badges posted today going forward have deadlines per the [syllabus](https://introcompsys.github.io/fall2023/syllabus/grading.html#deadlines)


## Why study what a commit is?

A commit is the most important unit of git. Later we will talk about what git as a whole isin more detail, but understanding a commit is essential to understanding how to fix things using git.


today we will continue organizing the github inclass repo as our working example.


In CS we often have multiple, overlapping definitions for a concept depending on our goal.

In intro classes, we try really hard to only use one definition for each concept to let you focus.

Now we need to contend with multiple definitions.

These definitons could be based on
- what it conceptually represents
- its role in a larger system
- what its parts are
- how it is implemented

## Using a GitHub Codespace

Today we will also work in github codespaces.

1. Navigate to your github inclass repo on Github.com
2. Use the link in the README or the green code button to open a new codespace on main.


You are allowed to have two active code spaces at any point in time. If you get an error, you have some still open. Use the [codespace page](https://github.com/codespaces) to see all of yours.

You can deacitvate any that are running that you do not want to use.


```{important}
Remember: codespace is a virutal machine on a cloud platform, not cloud access to github.com
- you need to commit changes
- codespace is linux
```


**this is why i teach bash**

as developers, we will all interact with linux/unix at times, so bash is the best shell to know if you only know one or do not want to switch between multiple


## Multiple cursors are your friend

[docs](https://code.visualstudio.com/docs/editor/codebasics#_multiple-selections-multicursor)

We used multiple cursors to remove the `>` from the beginning of each line in the README file that we we made last class.





## Conceptually, a commit is a snapshot

![storing data as snapshots over time](https://git-scm.com/book/en/v2/images/snapshots.png)



## A commit is the basic unit of what git manages

All other git objects are defined relative to commits


- branches are pointers to commits
- tags are pointers to commits



## parts of a commit

We can use `git log` to view past commits


here we see some parts:
- hash
- (if merge)
- author
- time stamp
- message

but we know commits are supposed to represent some content and we have no information about that in this view


we can view individual commits with

`git cat-file`

Now we see more detail:


- hash (used to access)
- tree
- parent
- author with timestamp
- commiter with timestamp
- message



## Commit parents help us trace back

kind of like a linked list


## Commit trees are the hash of the content

This separation is helpful.

Let's make a commit that includes changes to two files

After the commit we can use

```
git reset HEAD^
```

References until the full notes are added:
- [git reset](https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified)
- [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
- [Tooling and examples of conventional commits](https://www.conventionalcommits.org/en/about/)
to put the head pointer back and reset the working directory back to how it was at that point as well.

The [git reset](https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified) docs describe this in great detail.

## Commit messages are essential

A git commit message must exist and is *always* for people, but can also be for machines.

the [conventional commits standard](https://www.conventionalcommits.org/en/v1.0.0/) is a format of commits

if you use this, then you can use automated tools to generate a full change log when you release code


[Tooling and examples of conventional commits](https://www.conventionalcommits.org/en/about/)

## Review today's class

Expand All @@ -33,6 +186,8 @@ References until the full notes are added:

## Experience Report Evidence



## Questions After Today's Class

```{admonition} GitHub practice for questions
Expand Down
Loading

0 comments on commit b3885c6

Please sign in to comment.