GitKraken
Multiplatform, robust and featureful
Adds another app to your workflow
Git lingo, simplified
Repo(sitory): A collection of all versions of your files
Locally, a hidden .git folder in your working directory (WD)
May also be hosted online (e.g. GitHub, GitLab, Bitbucket)
Commit: One particular version/snapshot of your WD
A repo is a collection of commits
Basic workflow behavior:
Save (CtrlS) as much as you want between commits
Saves are ignored, only commits matter (unlike Dropbox)
Hash: a 40-character unique alfanumeric identifier of a commit
a4508a3d857eg282aced33ba75d18ede34fde99f
Pointer: a word reference to a commit (e.g. HEAD, main, origin/main)
Where does Git store your files?
Working directory (i.e., not Git): the files as you see and work with in your file explorer
Staging area: a list of files that are ready to commit
Repository: all previously commited version of your files
Basic Git Commands
(yes, we're finally starting for good )
Initializing a repository
git init # within working directory
Configuring your user info
git config --local user.name "$name"# or --global for the whole system
git config --local user.email "$email"# GitHub user? use your GH e-mail
Tip: Peek at your config file (git config --list)
Top tip: Add some aliases
Doing some actual work
First do some science
Then commitโi.e. register on Gitโa version of your science
git status
git add $file# Pro tip: --patch to hand-pick changes
git commit -m "$message"
git log# Pro tip: try these options: --oneline --graph --all
Go make more science
See what you have done
git status # Pro tip: wrap with "watch" to auto-update
git diff $file
git commit --all --message "$message"# Pro tip: fix an oopsie with --amend
git show HEAD:$file
...and those are the Git basics
Everyday registration of your work
Work on files
Add them to the staging area (git add)
Commit them to the repo (git commit)
Eventual consultation of a previous version
Check out the Git tree (git log)
Compare versions of your files (git diff, git show)
Intermediate Git flash-course
Undoing changes
git reset $file# unstages $file
git reset $hash# undo commits after $hash, but keep the changes
git reset --hard $hash# go nuclear (i.e., lose changes after commit)
Peeking at a file's change history
git log -p $file
git show $hash:$file# Pro tips: pipe (|) to "less"; redirect (>) to file
Tagging
git tag $tag_name
Git's greatest strength
(in my opinion)
Creating parallel versions of your files
Git is like a tree
Tree: repo
Leaves: files
Branches: different paths of development
In other words: you can have different versions of the same file on different branches!
Git is not like a tree
Expect your branches to merge back with the trunk(s)
Create a file called .gitignore and chuck all that in it.
Example:
When Git doesn't let you switch branches
a.k.a. "soft commit"
git stash # 1. Sweep a temporary version under the rug
git pop # 2. Retrieve it when you switch back
Preview of day 3: working with remote repos
git clone# Create a local copy of the remote repo
git fetch # Sync the remote pointer
git pull # Sync the local pointer with the remote
git push # Sync the remote pointer with the local