Lesson 18 Making Changes, Adding Comments

Today we’re going to make changes to our website and then push those changes online. When we “push” using Git and Command Line, we are getting those files off our computer and into the repository, the online box holding it all for us.

When someone goes to your URL, your web address, it’s going to open that box and find your index.html file and show it to them. In your repository should be all the pages, images, and videos for your website. Soon we’ll be adding files that give it style and that make your page do things!

If you don’t have anything to fix on your page, then you can add comments to your project to make a change to it, since we’re practicing updating our website. Even if you do have something to fix and update on your site, add comments today before you push the changes. What are comments and why take the time?

Comments are notes to yourself and to any other developers. Comments make it easier to read your code. You can easily see what each section in the code is for. You can label things to help you come back and adapt the code in the future. Comments let you, and anyone else seeing your code, know what’s happening in the code. I also like to put a comment at the end of each div (</div>) to label what section it is closing. There will come a time when your code will have several divs closing in the same place. Labeling each one helps me know where to insert something if I go back into the code.

To make a comment you put  <!- –  in front of it and  – ->  after it. In Atom the comments will appear gray making it easy to spot them and to make sure you have your comments closed.

Another useful feature of comments is to comment out code. Just put the comment tags around it and it will just be thoughts the computer keeps to itself instead of sharing them on your page. That way you can try your page without something, without having to delete the code in case you decide to keep it.

To get your changes online you open your Git command line program. Navigate to your directory using cd (for change directory) and ls (for list) as necessary. Once in your firstProject directory, type:

git add .   

Between git add . and git commit, you can type git status and see what files in your project have changed and will be updated on the website. You never again have to type the -u when pushing. If you have made lots of changes, but only want the changes to, say your index file to go online, then you could type git add index.html. Then it will only “stage” your index file for committing to go online. It would leave the rest of the changed files online. You don’t have to push everything, it’s just convenient to, and most often you are going to want all of your changes online.

git commit -m “Add comments.”          

git push origin master

You can watch the lesson as well! Subscribe to the site and to the YouTube channel to not miss new lessons.