Terminal Commands

  • pwd – Show current directory structure.
  • date – Show current date on system.
  • cd [foldername] | - | ../ | ../../ – Go into folder name cd – move 1 folder back. cd ../ Move 1 folders back. cd ../../ Move 2 folders back.
  • ls | -a | -alls List Directories. ls -a List All including hidden. ls -alList All Files with file permissions.
  • start . | [filename] – Open GUI of Folder. Open file name. (This only works on windows)
  • explorer.exe . | [filename] – Open GUI of Folder (This will work on Linux and Windows and Linux Subsystem).
  • curl [weblink] -o [newname] – Saves a file from the web to your local folder you are in.
  • echo [some text you want to write] – Output on the next line.
  • history – See history.
  • touch [filename.ext] – Create new file.
  • mkdir [directoryname] – Create directory
  • rm [filename.ext] – Delete file.
  • rmdir [directoryname] – Delete Empty Directory Only
  • rm -r [directoryname] | -rf [directoryname] – Delete Directory and all its content including files Force Delete Directory and all its content including files. (Never use -rf unless you have to).
  • cp [filename] [filelocation] – Copy file.
  • cp -r [directoryname] [newdirectorylocation] – Copy directory content to new location.
  • mv [sourceitem] [destinationitem] – Move Items Files and Directories
  • find . -iname * [text] * – Search files within directory and sub directories. The * is used for anything either before or after the text. E.g. *text (after) text* (before). Note: Make sure you wrap your search text in quotes. E.g. “search-term*” or “**search-term” otherwise you might get back nothing or an error.
  • unzip [filename] – Unzip file.
  • cat [filename] – Prints to screen what is in the file.
  • clear – Clear screen.
  • exit – Exit Terminal.
  • q – Exit file.
  • ping 10.1.1.1 – Check to see if you are connected and your computer is pinging to the internet.
  • Ipconfig - Displays your DNS info.
  • mklink /J [destinationfolder] [referencefolder] | /D [destinationfolder] [referencefolder] – You can create reference folders. By doing this you can access everything in one place without creating multiple folders. /J These are junction Links. /D These are directory links. You can use directory link on network folders, but you cannot with junction links. Use junction links for local folder and use directory links for local to network folders.

Setup SSH on GIT and GitHub

Note: Make sure you are in your home default user directory
ssh-keygen -t rsa -b 4096
This creates your ssh keygen. It will prompt you to enter a passphrase. This is sort of like a password for your ssh keygen. Once created it should be stored in your user folder.
cd .ssh Once you are in this folder. Open id_rsa.pub copy this key and save it on your GitHub. Once you saved it every time you pull a repository you don’t have to pass it credentials because your ssh keys are stored in GitHub.
To delete your ssh keys you can delete the .ssh folder. To regenerate ssh keys run through these steps again.

Setup GIT

Note: if you set up SSH git you don’t need to pass in your username and password (access token). Because every time you push and pull from GitHub it will ask for username and password (access token).
To set up global configuration.
Insert your username inside the double quotation marks.
git config --global user.name [your-github-user-name"]
Insert the email on your Github account inside the double quotation marks
git config --global user.email [your-user-email"]
Note: You can also manually edit the .config file in the .git folder in the root of your local project repository. This is a better way to do it. So, you can only make changes to the repository without making changes on all your other repositories.

Git Stuff

  • HOME=[directory] – Choose home directory for current git session. Changes Global variable for current session. Will revert back when you close current session.
  • git config --list – List your Git configuration.
  • git init –Start your git repository and start tracking files. This will create a .git folder in your current directory.
  • git clone [repositoryurl] – Downloading the latest version of a remote project repository into your local computer.
  • git branch – get all the updates from the remote repository, including new branches.
  • git branch [branchname] | [branchname] [sha] – Create new branch. Creates a branch from a past commit.
  • git branch | -a – If you want to see your local and remote branches.
  • git branch -d [branchname] | -D [branchname] – Delete branch. Force delete will delete unsaved work in branch.
  • git log | --oneline – To see commit details or to see one line preview of commits.
  • git log --stat | --stat [sha]– To see commit in more detail including author, date and files worked on. (You can get the sha when you run the previous command)
  • git log --graph – To see tree structure of branch and commits.
  • git log --graph --decorate --oneline – A easy way to see all commits and line tree and tags.
  • git log -p – Shows full changes to files. This is a patch output.
  • git log -n [numbercount] – Show logs limited to number count.
  • git reflog – List operations (e.g. checkout commits) made on local repository.
  • git add --all | -A | . – Add new files. This is called staging.
  • git commit -m [commitmessage] | --amend -m [commitmessage] – Commit changes to repository. Amend previous commit message. Make sure you put commit message in double quotes.
  • git commit -a -m – Bypass staging and just commit message. Stage and commit together.
  • git status – Check to see if there are any staged files. If in red you need to stage them.
  • git push – Push commits to remote repository.
  • git push -u origin [branchname] – Push your local branch to remote repository with tracking upstream.
  • git push -u origin [local_branch]:[remote_branch] – Push your local branch to another remote repository branch with tracking upstream.
  • git remote -v – Show the associated remote repositories and their stored name and show links to branch.
  • git remote show origin – Show if your remote branches are tracked. Get more info about the remote repository.
  • git push -d origin [branchname] – Delete a remote branch.
  • git pull – Update your local working branch with commits from the remote and update all remote tracking branch and apply changes to local branch.
  • git fetch – Pulls changes from remote but will not apply it to your local branch. Use “git pull” for that.
  • git stash | --all – Stash away unstaged items. This helps you jump between branches.
  • git stash apply | pop – Gets unsaved documents and keeps it ready for staging.
  • git stash drop – Delete stashed items.
  • git checkout [branchname] – Checkout from current branch and go to another branch.
  • git checkout -b [branchname] – Checkout from current branch and create a new branch.
  • git checkout -b [branchname] origin/ [branchname] – create a new branch off remote.
  • git diff | --staged – See changes made between each other unstaged or staged files.
  • git merge [branchname] – Merge from another local branch.
  • git rebase [branchname] – Brings your current branch up to date with a branch already ahead of your branch.
  • git tag [tagname] | - d [tagname] – Add tag. Delete tag. Tags are attached to your commits.
  • git tag -a [tagname] [sha] – Add a tag to a commit already made.
  • git reset – Remove files and move files back to unstaged.
  • git revert [sha] – Reverts your commit from sha. You can see file in earlier state from that commit point.
  • git reset --soft [sha] | --hard [sha] – Removes files and move files back to staged position. Hard reset moved files back to an earlier state. Note: when in earlier state you can git reset --soft [sha] | --hard [sha] then git push -f to hard reset or soft reset in the origin repository. Avoid using hard reset unless you really need to. – Removes files and move files back to staged position. Hard reset moved files back to an earlier state unsaved. Note: when in earlier state you can git reset --soft [sha] | --hard [sha] then git push -f to soft reset or hard reset in the origin repository. Avoid using hard reset unless you really need to.