Today:
npm install nodemon -g
to install this globally to use in all of your projectsnodemon main.js
Version Control is the practice of saving copies or snapshots of your code at each significant stage as you work on a project. Like a meta-undo, version control lets you move forward and backward in time to get to different versions of your code across a project’s files. Without version control software, you might take a DIY approach by copying a project’s entire directory and naming it with the date. But what if you want to make multiple copies with slightly different versions and you want to use parts of each of these versions? What if you want to share and work simultaneously on a project with partners? How can multiple people collaborate together over time? Version control software lets you do this.
Git is local version control software that you run on your own computer. It lets you track changes to your files incrementally over time. Each project has its own git files. GitHub is a software company as well as the name for the website where you can post your projects you are tracking with git. You take copies of your git-tracked programs and push them to a remote GitHub server. You should know there are alternative websites and repository managers including GitLab, Bitbucket, SourceForge and others. In this article, I’ll only be covering GitHub.
I also recommend Version Control By Example, an affordable and easy-to-read book, along with free online version.
On a Mac, you get Git when you install XCode or the XCode Command Line Tools.
You should only need to do this section once!
Set the default name for git to use when you make a commit.
git config --global user.name "Your name Here"
git config --global user.email "your_email@example.com"
Use git init
to initialize tracking your project folder aka your local repository.
git add hello_world.txt
git status
Your file is now being tracked by git. Let’s tell git to commit the file.
git commit -m "First commit. Added hello world to repository."
Make sure you include the -m
flag. Without it, your Terminal application will likely launch Vim, a text editor, and it’s not particularly beginner-friendly.
What did we just do? How is this different than saving a file?
git add filename
to stage a file. When we stage an existing file, we are telling Git to track the current state of the file.We will work in our IDE and each time we get to a good stopping point/save point, we will save our file(s) inside our repository folder. Then we head back to the Terminal, make sure we cd
into our repository folder if we’re not already there.
Then we add and then commit our changes.
git add fileWeChanged
If we have multiple files we’ve changed:
git add file1 file2
Now let’s commit them.
git commit -m 'fixed our header'
This is the commit message so we know what we changed in this version of our code.
We continue this process in a loop. We work in our IDE. We save. When we are ready we return to the Terminal, add our files, then commit them with a message.
git log
OR
git log --pretty=oneline
There is a GUI/Graphical Interface should you prefer to use one.
In general, there are more options when working in the command line.
You may wish to work on several copies of your project with slightly (or dramatically) different codebases. Maybe you have a desktop and a mobile version of your project, or one for Mac and PC, or regular and experimental versions.
For each version you can create a different branch.
git checkout -b version2
git branch
Maybe you were working on a stable branch and an experimental branch and you want to merge these two together. Generally, your first and main branch is called the master branch. You can merge your version2 with your master.
git merge version2
Git is the software you use on your local computer to track your repository’s files. You can always work in Git and not use GitHub if you just want to track your changes locally. However, if you want to make backup copies stored on a remote server, or work collaboratively on code with others, you’ll want to put your code online. GitHub is a great way to do that and it works seamlessly with Git.
mkdir hello-github
cd hello-github
git init
We’ve made a project folder. Moved inside it. And initialized it so that Git will be used for tracking our files over time.
We want our remote GitHub repository to be a copy of the important commits (aka snapshots of our project’s complete code files).
Let’s connect our local repository to a GitHub repository.
On github.com let’s create a repository. Click the + button. Give the project a name. Initialize it. It will give you a git URL. Copy it.
Now go back to your Terminal. To connect our local repository to the one hosted on GitHub, we run:
git remote add origin git://github.com/github-name/project-name
After you’ve connected your local repository to the GitHub one we need to run this command for the first time.
git push -u origin master
Going forward our standard protocol will be to just run
git push
This takes our committed files and pushes a copy to our GitHub repository.
It is considered good form to make a README.md file in Markdown text and saved in the root directory of your repository. This can contain basic info on the project, starter information, or anything else. GitHub will automatically present this file when someone visits your repository’s page.
git add README.md
git commit -m 'added README.md'
git push origin master
We use Git to track files locally, and GitHub to store our code remotely and to collaborate with others. GitHub can also be used to host a website with GitHub Pages.
mkdir project-folder
. If you already have a folder for this project, skip creating the folder. In either case go to it cd project-folder
.git remote add origin http://github.com/username/projectname.git
If the repo already existed, then go to the project page on github and click the green Clone or download button and you can copy the URL from there. Use the same git remote add origin command.git add filename
You can add multiple files at once git add file1 file2 file3
Staging does not save a snapshot of the entire. It just prepares them.git commit -m 'initial save of my files'
git push
i
You can also have a css
stylesheet as normal and javascript, jquery, or any other file as long it’s static.git add index.html
and git commit -m 'created a project site page
and git push
to push this to the GitHub repository.This semester we have built websites for our class, false or misleading institutional websites, various extensions that hack the browser’s defaults, a chatroom, chat server bots, synced networked websites with servers, and more. These sites have been collections of material: images, galleries, or institutional pages with lots of choices of what to navigate. They give a user multiple modes of entry and allow exploration. Now we are going to go small and concentrate on creating a site, app or extension for a single project or idea that we want to deliver to the world that will be delivered as a speculative work.
We have had multiple discussions on contemporary issues relating to the web today, from companies tracking users’ every action, to the loss of privacy and the inability of many users to resist the compulsion to check their various feeds. How can you acknowledge this world and create a new intimacy with your website’s visitors?
For this assignment you will make a project that uses a server, a responsive site or combination. This can be something to bring people together in a holistic manner, artistic, or other kind of experience.
You can make an app, website or project that respects your user, plays with convention, or distorts a user’s expectations on the web. You are a unique individual and your work is too! Perhaps your site is playful, mysterious, a game, a poem? An experimental chatroom, online performance, networked game…
Project presentations will be in class during finals. We will have a series of smaller steps to accomplish leading up to that.