Decluttering my mind into the web ...
Git is a Distributed Version Control System (DVCS). It uses a directed acyclic graph (DAG) to model history (i.e., it supports branching):
o <-- o <-- o <-- o
^
\
--- o <-- o
Snapshots are modeled as follows:
<root> (tree)
|
+- foo (tree)
| |
| + bar.txt (blob, contents = "hello world")
|
+- baz.txt (blob, contents = "git is wonderful")
All snapshots are identified either by their SHA-1 hashes or their references (e.g., “master”).
$ sudo apt install git
$ git config --global user.name "your name" $ git config --global user.email "your email" $ git config --global core.editor "your favourite text editor"
$ git config --list
$ git help [command]
# full clone $ git clone <URL ending with .git> # shallow clone $ git clone --depth=1 <URL ending with .git>
# initialize repo $ git init # specify which files / directories to ignore $ vim edit .gitignore # check log, current status, difference $ git log [--all --graph --decorate] $ git status $ git diff [filename] # stage files $ git add <filename, leading directory, or use --all> # commit changes $ git commit ####################################################### # Optional: linking to a remote server (such as github) ####################################################### # link to a remote repo and verify $ git remote add [-t branch] <name, usually called "origin"> <URL> $ git remote -v # push changes to remote repo $ git push <remote name, normally "origin"> <local branch, normally "master">[:<remote branch>]
# show existing branches $ git branch # create and step into the new branch $ git branch <new branch name> $ git checkout <branch name> # merge current branch with a specified branch $ git merge <branch to merge with> # deleting a branch $ git branch --delete <branch name>
# ... hack hack hack ... $ git stash # make emergency fix $ git commit -a -m "Fix in a hurry" $ git stash pop # ... continue hacking ...