Coding Cheat Sheet - deepa-rao/Resources GitHub Wiki

Coding Cheat Sheet

Check the difference between texts

Terminal Commands

Command Description
pwd Full path to working directory
. Current directory, e.g. <ls.>
.. Parent directory, e.g. <ls..>
ls -ltr List files in chronological order
rm [file] Remove a file, e.g. <rm data.tmp>
rm -R [dir] Remove a directory and its contents
cp [file] [new file] Copy file to file
cp [file] [dir] Copy file to directory
cp -a /source/. /dest/ Copy folder contents into a new directory
mv [file] [new filename] Move/Rename
mkdir [dir] Create new directory
mkdir -p [dir]/[dir] Create new directory and nested directories
grep [search_pattern][file] Search for all lines that contain the pattern, e.g. <grep "Deepa" file.txt>
whatis [command] Gives a one-line description of [command]

Vi Commands

Command Description
vi [filename] Open file via Vi editor
:x Exit, saving changes
:q! Exit and ignore any changes
i Insert text before cursor (insert mode)
h move left
j move down
k move up
l move right
:wq Write to file and quit

Git Commands

Command Description
git init Create a new local repository
git status List all new or modified files in working directory
git diff Show file differences that haven't been staged
git add . Add all current changes to the next commit
git commit Commit previously staged changes
git commit -m "message" Annotate your commit
git log Show all commits, starting with the newest
git log clip
git log --no-pager log > log.txt Write log to text file
git log Show commits for only this file, starting with the newest
git log Show commits for only this folder, starting with the newest
git help [command] Get help on the command line
⚠️ **GitHub.com Fallback** ⚠️