Design Portfolio


This Week I Learned | Git Basics and JavaScript Basics

Git Basics

  • VCS - version control system
    • allows developers and designers to all work on the same code base
  • running git init without a name will create a repository in the folder you are currently working in
  • everything important about the repository is stored in the .git folder, 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 log to see past commits
  • check a version out using git checkout and the first 5-6 characters of the commit hash
    • get two commits and browse the differences between them

Branching Out

  • master is 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 checkout to 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 master
  • 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 master to 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
  • then git add [file] and git commit -m "message"

JavaScript Basics

  • string values are immutable - they cannot by altered once created. This means the individual characters of a string literal cannot be changed.

Cannot do:

var myStr = "Bob";
    myStr[0] = "J"; // -> "Job"

Can do:

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 var keyword), it will automatically become a global variable.
  • the lifetime of JavaScript variables begins when they are declared
    • 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