How to use the Repl: 1. Right click on any Chrome browser and click inspect 2. Click the Console
tab on the interface that opens 3. Right any JS code in the console
NodeJS has… | Browser has… |
---|---|
- “global” object named global |
- “global” object named window |
- NodeJS-specific objects like process |
- browser-specific objects like location and document |
- a require function to import another .js file |
- no require function |
- access to node_modules like readline |
- no access to node_modules |
fs
(file-system) built-in node module will allow us to read and write to filesfs
has synchronous and asynchronous versions of the same function so make sure you pick the right one!fs.writeFile
and fs.readFile
are asynchronouscommit
- a saved version of your current folderbranch
- a linear series of commit versions HEAD
- last committed change to the branch you are currently onmaster
branch - first created branch when initializing a git repositorymerge
- can merge commits on one branch into another branchgit init
- initializes a git repository in a folder - creates a hidden folder, .git
, can be seen by using command, ls -a
- DO NOT initialize a git repository on your Desktop or your root! - DO NOT have a nested git repository!! (a folder with a git repo in a folder with a git repo) - If you do any of the above, you can delete the hidden .git
folder created with: rm -rf .git
>> PLEASE MAKE SURE TO WRITE THIS OUT EXACTLY BEFORE PRESSING ENTER!!!! IF YOU DON’T DO IT EXACTLY, YOU MAY DELETE OTHER THINGS OR THE ENTIRE CONTENTS OF THE FOLDER!!!! THEY CANNOT BE RECOVERED
git status
- checks if there is a git repository and the status of your git repository
git add {FOLDER/FILE PATH}
- adds folder or file specified to your staging area from your working directory
git commit -m 'Write your commit message here...'
- adds all items in your staging area to your local repository bundled as a new version or commit
git log
- see your past commit history (past versions)
git log --oneline
- shortened version of the above command
git diff
- used to compare two versions, or points of time, in a git repository - without arguments, will display the difference between the working directory and the last committed version
git diff --staged
- compare changes between staging area and last commited version
git diff {INSERT YOUR COMMIT HERE TO COMPARE}
- compare changes between last commited version and the argument to git diff
git branch
- will show all branches and what branches you are currently on
git checkout -b {insert-name-of-branch-here}
- creates a new branch with the given name and checks it out
git checkout {branch-name}
- checks out the branch given
git reset
git reset --soft {INSERT A COMMIT TO ROLLBACK TO HERE}
- will rollback changes to the commit specified AND will add the changes in the commits rolled back to the STAGING AREA
git reset --mixed {INSERT A COMMIT TO ROLLBACK TO HERE}
- will rollback changes to the commit specified AND will add the changes in the commits rolled back to the WORKING DIRECTORY - is the default reset (git reset INSERT A COMMIT TO ROLLBACK TO HERE}
will do a mixed reset)
git reset --hard {INSERT A COMMIT TO ROLLBACK TO HERE}
- will rollback changes to the commit specified BUT will REMOVE all the changes in the commits rolled back - NO WAY TO GET ANY OF THE CHANGES BACK IN THE COMMITS REMOVED
git remote add {name-of-remote} {remote-url}
- adds a remote repository with the given tag name for the url
git rebase
git rebase {BRANCH NAME or COMMIT HASH}
- takes the HEAD of the branch name or the commit and uses it as the start point of the current branch
git rebase --abort
- only if there is a rebase conflict, this will abort the rebase
git rebase --continue
- run this after you add all the changes to staging to continue with the rebase (make sure to run git status
to see if you still have conflicts after you continue)
git merge
git merge {other-branch}
- will take the other branch’s commits and add it into teh current branch - If there is no merge conflict when running merging, then the new commits from the branch you are merging will be added to the master branch
git merge --abort
- only if there is a merge conflict, this will abort the merge
git merge --continue
- run this after you add all the changes to staging to continue with the merge (make sure to run git status
to see if you still have conflicts after you continue)
git checkout
git checkout {BRANCH NAME or COMMIT HASH}
- used to force the HEAD to be at the checked out branch or commit on a detached branch (Not recommended. Just checkout a new branch and reset the commits on the branch there.)
git checkout -- {FILE NAME}
- used to reset the file specified to be the same as the HEAD’s version
git config --global user.name {INSERT NAME HERE}
- sets your global git user’s name and displays that for every git commit you make
git config --global user.email {INSERT EMAIL HERE}
- sets your global git user’s email and displays that for every git commit you make
git push -u {REMOTE REPO TAG NAME} {BRANCH NAME}
- sets the upstream for the branch to the remote repo and branch so your local git repo will track changes between itself and the remote repo (can see those changes with git status
)
If you want VSCode to be the editor that opens when changing commit messages, do EDITOR="code --wait"
in your terminal.