UofT ECE 467 (2022 Fall) - Quick References



The website and starter code is being pre-emptively updated!

I don't know if I'll be teaching the course again, but if I wait until next year I'll forget feedback I've received. Note that more test cases have been added (if you pull the new starter code); those are for the (potential) future!


In general, search engines are your friend. Additionally, I highly encourage you to read through man pages/--help for command-line tools. Personally, these command-line documentations used to scare me, but once I overcame that fear, I found them to be extremely informative.

git

Manual.

clone a repository
git clone <url> <optional target directory/path>
show status
git status
stage files for commit
git add <files...>
stage all tracked files for commit
git add -u
show diff for modified files
git diff [optional commit specifier] (by default relative to HEAD, the most recent commit)
git diff [optional commit specifier] -- <files...>
tip: you can suffix a commit ID (or HEAD for the latest commit) with however many (say n) carets (^) to refer to however many (n) commits before it; e.g. HEAD^ for the 2nd latest commit.
tip: you can suffix a commit ID (or HEAD) with ~<n> to refer to <n> to refer to <n> commits before it; e.g. HEAD~2 for the 3rd latest commit.
show diff for staged files (relative to HEAD)
git diff --cached
git diff --cached -- <files...>
show diff between two commits
git diff <older commit> <newer commit>
git diff <older commit> <newer commit> -- <files...>
show history
git log
unstage files
git restore --staged -- <files...>
discard changes to files
git restore -- <files...>
commit
git commit
git commit -m "one line message"
add your own git server/repository (e.g. GitHub)
git remote add <name> <url>
push to your own git server
git push <name> master

tmux

tmux manual.

start a session
tmux
tmux new -s <name>
detach from a session
ctrl-b d
reattach to a session (add flag -d to detach other sessions)
tmux attach
tmux attach -t <name>
list sessions
tmux ls
create a new window
ctrl-b c
switch to the nth window
ctrl-b <n>
list windows
ctrl-b w
split window into vertical panes
ctrl-b %
split window into horizontal panes
ctrl-b "

gdb

gdb manual.

debug an executable
gdb <path/to/executable>
note: you do not pass arguments to your executable here.
run executable inside GDB
r <args...>
e.g. r 4 ../test/lab4/collatz.c
get a backtrace
bt
inspect a call frame
f <n> where <n> is the frame number obtained from the backtrace
print a value or expression
p <expr>
tip: you may even access fields, dereference pointers, and call methods.
set a breakpoint
b <function>
b <file>:<line number>

Last updated: 2022-12-23 09:56:36 -0500.