- Git is a distributed version control system
- It is a Linux community project released in 2005 as a replacement for BitKeep (proprietary) that the linux community had used prior as a VCS for the linux kernel
Snapshots not Differences
- Unlike a lot of other VCSs, git stores snapshots not differences (called delta-based version control)
- Delta-based version control,

- Git’s version control (stream of snapshots),

User view
- Users get to see three different files states and each git project has three areas
- File states in git,
- Modified
- Staged
- Committed
- Three areas in a git project,
- Working tree - single checkout of one version of the project
- Staging area - a file that has information on what will go into the next commit
.gitdirectory- Metadata
- Object database - compressed snapshots of all files
Related
git rm FILE
git rm --staged FILE
git mv from_file to_filegit log --stat
git log --pretty=oneline/short/full/fuller
git log -S function_name
git log -- file_nameHelpful Config Stuff
git config --global user.name ""
git config --global user.email ""
git config --global init.defaultBranch main
git config --list
git config user.name
git config --list --show-origin #see all your settings and where they are coming fromCreating aliases,
git config --global alias.staash 'stash --all'Run a script and pretend like it’s a git command,
git config --global alias.bb !better-branch.sh
# ! - indicates shell scriptHaving an intermediate git config btw local .gitconfig and global .gitconfig,
[includeIf "gitdir:~/projects/work/"]
path = ~/projects/work/.gitconfig
[includeIf "gitdir:~/projects/play/"]
path = ~/projects/play/.gitconfigOldies
git blame
git balme -L
git log -L 15,26:path/to/filr
git log -L :<function/ entity name>:path/to/file
# ignore whitespace
git blame -w
# ignore whitespace and detect lines moved or copied in the same commit
git blame -w -C
# ignore whitespace and detect lines moved or copied in the same commit or the commit that created the file
git blame -w -C -C
# ignore whitespace and detect lines moved or copied in the same commit or the commit that created the file or any commit at all
git blame -w -C -C -CGet the person who wrote those lines
Tell git to remember the merge conflict, remember how you fixed it and fix the same merge conflict, if it occurs again in the future
git config --global rerere.enabled truegit push --force-with-lease # safer than forcegit maintanance start # makes things fasterRefs
- “Pro Git” by Scott Chacon and Ben Straub