Command Line Helpers


NAVIGATION

Get the current directory’s path

pwd


List the files in the current directory

ls


Change directory

cd # exits to the root directory

cd ‘NameOfDirectory’ # changes to the specified directory

cd .. # backs out of the current directory


Make directory

mkdir ‘NameOfDirectory’ # creates a directory with the given name within the current scope



GIT

Check which files have been changed in the directory

git status


Pull remote changes on a branch

git pull


Add current changes to next commit

git add -A


Commit added changes to local .git repository

git commit -m "some message about commit"


Push changes to remote repository

git push


See changes by file

git diff


Removed tracked files after being added to .gitignore

git rm -r --cached .

git add .

git commit -m "removed untracked files"


Return list of local branches

git branch


Checkout a local branch

git checkout branch-name


Create a new branch !TIP! - This will include your uncommitted changes

git checkout -b branch-name


Stash your current changes to apply later or on a different branch.

git stash


Apply your stashed changes to the current branch.

git stash apply


Edit your commit history.

git rebase -i HEAD~number-of-commits-to-rebase


Reset all uncommitted changes to a directory.

`git reset —hard`


Reset a specific file.

`git checkout -- filename # not staged for commit`

`git reset HEAD filename # unstage a file staged for commit`

`git checkout origin/master filename # already committed`


Reset branch to match remote branch (VERY DESTRUCTIVE).

`git reset --hard origin/master`



!!!TIP!!!

First install Sublime text editor. (https://www.sublimetext.com/) Aliases work equally with other programs.

Then alias Sublime text editor by adding this to your .bash_profile

alias sublime="open -a /Applications/Sublime\ Text\.app"


Call this to make the changes affect your current terminal session

source ~/.bash_profile


Then call your new command to open the user level directory in sublime. I have my .bash_profile open here showing my alias for Sublime along with an alias for Xcode.

sublime ~/


This will show all of your local system files and folders that even finder wont show including your profiles.

bash-alias-example



BASH

Switch from alternate cli

exec bash


Profile

~/.bash_profile



ZSH

Switch from alternate cli

exec zsh


Profile

~/.zshrc



APT

Check list of installed packages via apt-get

apt list -—installed