Git Basics
Keywords
- stage - add a file to be committed
- commit - The state of the repository at this point in time is saved
- checkout - Refers to the creation or switching between branches or commits.
Concepts
Git is a version control system that allows one or more people to manage different versions of a repository. A repository can be though of as a project directory. A repository contains documents like text, code, and configuration files as well as images. The repository, often referred to as a "repo", also contains the change history called a commit history. Each commit is a saved version of the repo at that point in time. You can think of a commit history as a series of backups.
Basic Commit History
Create A Local Repository and Make a Commit
- Mac/Linux open a terminal
- Windows open Git Bash
- Create directory
- Navigate through the terminal to the root of the directory
- Type
git init
- Create a file called first-markdown.md and open it in your favorite text editor/IDE
- Write something in the file and save it
- In the terminal type
git status
git add first-markdown.md
git status
git commit -m "Some message here about what you did."
git log
- Repeat these steps. On each iteration attempt to new files, edit existing files, and/or delete files
TODO do a revert
Basic Commands
git init Creates a new git repository
git status Show status of staged/unstaged files
git diff See changes to the file compared to most recent commit
git add <file_name> Add file to commit (stage it)
git commit -m "<message>" Commit files with clear message about commit
git log Display a list of commits
git revert <commit id> Revert the commit with provided id