# Overview
A tool for version control, often used in programming. It also enables collaboration and managing conflicts. This is done by using a [[Directed Acyclic Graph (DAG)]] to model the files within a project.
## Diagram
![[Git 2024-11-21 12.57.32.excalidraw.svg]]
%%[[Git 2024-11-21 12.57.32.excalidraw|🖋 Edit in Excalidraw]]%%
![[Git 2024-12-03 06.17.45.excalidraw.svg]]
%%[[Git 2024-12-03 06.17.45.excalidraw|🖋 Edit in Excalidraw]]%%
## Key Terms
- Root - the top level of a project's repository (folder structure)
- Tree - a folder within a repository. A tree is a `map< string, tree | blob>`.
- Blob - a file within a tree. A blob is a `array<byte>`.
- Commit - the versions of the repository stored, which is related to other commits as part of a [[Directed Acyclic Graph (DAG)]]. A commit is represented as the below. The objects below are pointers to the objects, rather than the objects themselves.
```json
struct{
parents: array<commit>
author: string
message: string
snapshot: tree
}
```
- Object - a blob, tree, or commit that is stored to disk. An object is a `map<string, object`.
- References - mapping of the human-readable names to the location of a commit on disk. `map<string, string>`
## Key git Commands #flashcard
- `init` - initialize a folder as a Git repository
- `add` - add a file to be tracked by Git
- `commit` - save changes to the remote repository
- `-a` - commits all files that are being tracked
- `log` - shows the log for the
- `checkout` - can change the state of the working directory to another commit
- `branch` - lists all branches, or creates new branch
- `merge` - merge branches
- `clone` - create copy of a repository
- `fetch` - fetch and download content from a remote repository
- `pull` - fetch and download content from a remote repository and immediately update the local repository to match that content
- The same as `fetch`, then `merge`
- `push` - send changes from a local repository to the remote repository
<!--ID: 1751507777715-->
# Key Considerations
## Branching
## Additional Commands
- `blame` - see line-level details on the commit and author
- `bisect` - can use to find a first commit where a [[unit test]] fails
## Git Tools:
- [[Github]]
- [[Bitbucket]]
- [[Gitlab]]
# Implementation Details
# Useful Links
# Related Topics
## Reference
#### Working Notes
#### Sources
- [Git Pro - Book and Free PDF](https://git-scm.com/book/en/v2)
- [Lecture 6: Version Control (git) (2020) - YouTube](https://www.youtube.com/watch?v=2sjqTHE0zok)