- VCS - version control system
- allows developers and designers to all work on the same code base
git initwithout a name will create a repository in the folder you are currently working in
- everything important about the repository is stored in the
.gitfolder, so you can rename the folder holding your project files without causing any problems
git commit -a -m "message here"
-a adds all files.
-m is the message flag.
The Staging Area
git status- shows us the current version control status of our project
git logto see past commits
- check a version out using
git checkoutand the first 5-6 characters of the commit hash
- get two commits and browse the differences between them
masteris the default branch of any git repository
- often thought of as the trunk
- the version of code typically deployed in production
git branch [name]to create a new branch, use short and meaningful names
git checkoutto switch branches
git checkout -b [name]to create and switch to a new branch
- creating a new branch makes a copy of the branch you are currently in and uses it as a base for the new branch
git branch -D [name]to delete a branch
- merging brings your branches back to
- makes a cohesive timeline of commits
- merge conflict - happens when the same files have been changed in different branches
- resolve the conflict by deciding which changes are most important to keep
- in most cases, Git can and will automatically resolve merge conflicts for you
git checkout masterto switch to master, then
git marge [name_of_branch_to_merge]
Resolving Merge Conflicts
- when automatic merging fails, you will need to resolve conflicts manually by
- remove conflict markers to keep both sets of changes
- delete one change
- combine both changes
git add [file]and
git commit -m "message"
- string values are immutable - they cannot by altered once created. This means the individual characters of a string literal cannot be changed.
var myStr = "Bob"; myStr = "J"; // -> "Job"
var myStr = "Bob"; myStr = "Job";
Can only change a string by completely replacing it.
- if you assign a value to a variable that has not been declared (no
varkeyword), it will automatically become a global variable.
- local variables are deleted when the function is completed
- global variables are deleted when you close the page
Global vs Local Scope in Functions
- when both local and global variables have the same name, the local variable takes precedence
- queue - an abstract data structure where items are kept in order
- new items are added to the back of the queue
- old items are taken off the front of the queue