<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brian</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Brian"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Brian"/>
	<updated>2026-11-15T21:04:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2178</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2178"/>
		<updated>2016-11-22T18:51:12Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           npm install -g bower&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 7). You are allowed to demo your assignment at TA office hours. However, after Friday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-10 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
'''Creative Project Rubric'''&lt;br /&gt;
&lt;br /&gt;
You will also be submitting your Creative Project rubric alongside Module 7. Make a new repo &amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-CP-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2, and place your Creative Project rubric in a README.md in that repository. &lt;br /&gt;
&lt;br /&gt;
Your Creative Project point breakdown should total to 95 points. An additional 5 points come from submitting the rubric on time. You may assign up to 20 points for the creative portion. &lt;br /&gt;
&lt;br /&gt;
The project itself, you will be using a new framework or technology of your choice to build a project. &lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2176</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2176"/>
		<updated>2016-11-21T16:52:49Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 7). You are allowed to demo your assignment at TA office hours. However, after Friday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-10 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
'''Creative Project Rubric'''&lt;br /&gt;
&lt;br /&gt;
You will also be submitting your Creative Project rubric alongside Module 7. Make a new repo &amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-CP-FirstName-LastName-StudentID, and place your Creative Project rubric in a README.md in that repository. &lt;br /&gt;
&lt;br /&gt;
Your Creative Project point breakdown should total to 95 points. An additional 5 points come from submitting the rubric on time. You may assign up to 20 points for the creative portion. &lt;br /&gt;
&lt;br /&gt;
The project itself, you will be using a new framework or technology of your choice to build a project. &lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2172</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2172"/>
		<updated>2016-10-27T18:52:00Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may (and should) use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your HTML document.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' http://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#: We kindly thank Yahoo Weather for providing us with up-to-date weather information.&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but if you're up for a challenge we encourage you to look at other database options like [[wikipedia:MongoDB|MongoDB]].&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
* '''Optional:''' Validate your JavaScript code using [http://www.jshint.com/ JSHint] '''''or''''' [http://jslint.com/ JSLint] for up to 3 points of extra credit.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 5). You are allowed to demo your assignment at TA office hours. However, after Friday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share your repo with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (10 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and encrypted; if using OpenID, you are storing the user's OpenID identifier in the database (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#** ''Extra Credit:'' Your code passes ''JSHint'' or ''JSLint'' (+3 bonus points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
#*  '''Make sure to save a description of your creative portion, and a link to your server in your README.md file.'''&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2170</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2170"/>
		<updated>2016-09-12T15:11:55Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 75 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 6). You are allowed to demo your assignment at TA office hours. However, after Friday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (5 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (2 points)&lt;br /&gt;
#** node_modules folder is ignored by version control (1 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Apache&amp;diff=2169</id>
		<title>Apache</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Apache&amp;diff=2169"/>
		<updated>2016-09-09T22:15:30Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* The UserDir Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''Apache'' is the industry standard web server for Linux distributions.  It is highly configurable and has a wide range of modules ready for different needs.&lt;br /&gt;
&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=permanence&lt;br /&gt;
|id=910&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== What is a web server? ==&lt;br /&gt;
&lt;br /&gt;
A web server is software that listens for connections to your machine, and when a connection is receive, processes the request and responds with the appropriate information.  Most web servers listen on port 80, which is reserved for the purpose, and use the HTTP protocol.&lt;br /&gt;
&lt;br /&gt;
For example, when you visit this wiki, you are sending a request over the internet to some machine that is probably located somewhere in EIT (the user seldom knows exactly where the machine is located).  The web server receives your request, and it processes the data you sent.  Finally, the server prepares a response (the web page), and sends it back to you.&lt;br /&gt;
&lt;br /&gt;
== Installing Apache ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
In yum, Apache is distributed under the package name '''httpd''' (for ''hypertext transfer protocol daemon'').  In apt, it is distributed under the name '''apache2'''.  Use the package manager associated with your distribution to install Apache.  (For more information on how to use yum and apt, see [[Linux#Repository-Based Package Managers|the Linux guide]].)&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Debian version&lt;br /&gt;
$ sudo apt-get update&lt;br /&gt;
$ sudo apt-get install apache2&lt;br /&gt;
&lt;br /&gt;
# RHEL version&lt;br /&gt;
$ sudo yum install httpd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When Apache is installed through apt, the HTTP Daemon will be automatically to added as a startup item.  If you are using the Amazon AMI, you need to run this command to add Apache as a startup item:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --levels 235 httpd on # RHEL only&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In RHEL, all Apache configurations are stored in ''/etc/httpd/conf/httpd.conf''.  Debian takes a more modular approach, having separate directories for each type of configuration, all located in ''/etc/apache2/''.  For more detail on Debian's approach, see http://www.control-escape.com/web/configuring-apache2-debian.html&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Apache Directives ==&lt;br /&gt;
&lt;br /&gt;
You define your settings for Apache using ''directives''.  Some of the directives you will likely encounter include:&lt;br /&gt;
&lt;br /&gt;
* '''DocumentRoot:''' The path to the directory where the top level web files are going to be stored.&lt;br /&gt;
* '''IfModule:'''  The following block would be included if specified module exists.&lt;br /&gt;
* '''User:''' Which user apache2 will run as.&lt;br /&gt;
* '''Group:''' Which group will have group access to default web files.&lt;br /&gt;
* '''AccessFileName:''' The name of the access file (that specifies user names/passwords and other limitations to files/directories).&lt;br /&gt;
* '''ErrorLog:''' Where any errors will be written.&lt;br /&gt;
* '''Include:''' Include some other files.&lt;br /&gt;
* '''LogFormat:''' How to write a log message.&lt;br /&gt;
* '''ErrorDocument:''' Files to display for some HTTP errors (500, 404, 402 etc.).&lt;br /&gt;
* '''Alias:''' Map a directory URL to some other location on your filesystem.  Requires that the ''Alias'' module be loaded.&lt;br /&gt;
&lt;br /&gt;
=== .htaccess Files ===&lt;br /&gt;
&lt;br /&gt;
You can also specify some Apache configurations without delving into the master configuration file.  To do this, put a file named ''.htaccess'' in any directory that Apache is serving.  All directives in it will be interpreted as if they were in a Directory directive in the master configuration file.&lt;br /&gt;
&lt;br /&gt;
'''VERY IMPORTANT:''' The directory containing ''.htaccess'' must not have the '''AllowOverride None''' directive in the master configuration file in order for '''.htaccess''' to be read.  In Debian, '''AllowOverride None''' is enabled by default!  The Apache configuration file you need to edit in Debian is ''/etc/apache2/sites-available/default'' (remove the '''AllowOverride None''' located on line 11).&lt;br /&gt;
&lt;br /&gt;
=== Directory Directive ===&lt;br /&gt;
&lt;br /&gt;
Use the Directory directive to assign other directives to a specific directory.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Directory /var/www/&amp;gt;&lt;br /&gt;
	Options Indexes FollowSymLinks &lt;br /&gt;
	AllowOverride None&lt;br /&gt;
	Order allow,deny&lt;br /&gt;
	allow from all&lt;br /&gt;
	RedirectMatch ^/$ /apache2-default/&lt;br /&gt;
&amp;lt;/Directory&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sets options for the ''/var/www'' directory.&lt;br /&gt;
# The '''Options''' directive says that:&lt;br /&gt;
## If no index page is present in a directory, display a directory index page instead&lt;br /&gt;
## Apache will follow symbolic links in the directory&lt;br /&gt;
# '''AllowOverride None''' says that ''.htaccess'' files cannot alter the Apache options in this directory and all sub-directories&lt;br /&gt;
# '''Order allow,deny''' and '''Allow from all''' specifies that anybody is allowed to access this server via HTTP.&lt;br /&gt;
&lt;br /&gt;
Note that this directory is actually the root directory of the web server.&lt;br /&gt;
&lt;br /&gt;
== The UserDir Module ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
The UserDir module lets you access files for any user on the server with a ~, e.g., http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com/~paul/&lt;br /&gt;
&lt;br /&gt;
This module comes installed, but not activated by default.&lt;br /&gt;
&lt;br /&gt;
=== Enabling UserDir in Debian ===&lt;br /&gt;
&lt;br /&gt;
If you are using a Debian-based distribution for your server (like Ubuntu Server), simply run the following command to enable the module:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo a2enmod userdir&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then [[#Restarting Apache and Testing|restart Apache]] for the changes to take effect.  Now, all users will be able to store their own personal web site in public_html inside their home directory.&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working, create a test file in your home directory under public_html, and then point your browser to it: http://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/~yourUserName/hello.txt&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The UserDir configuration file, which already has all the correct settings, is located at ''/etc/apache2/mods-available/userdir.conf''&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Users need to manually create public_html.  It is not created automatically.&lt;br /&gt;
&lt;br /&gt;
=== Enabling UserDir in RHEL ===&lt;br /&gt;
&lt;br /&gt;
If you are using an RHEL-based distribution for your server (like the Amazon AMI), you need to edit the master Apache configuration file.&lt;br /&gt;
&lt;br /&gt;
Open ''/etc/httpd/conf/httpd.conf'' in your favorite text editor.  For more information on command-line text editors, refer to [[Linux#File Editors|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;UserDir disabled&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;UserDir disabled root&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally, find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;#UserDir public_html&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and uncomment it; that is, remove the # so that you have&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;UserDir public_html&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells Apache that the directory containing each user's html files is a subdirectory of their home directory called public_html.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Users need to manually create public_html.  It is not created automatically.&lt;br /&gt;
&lt;br /&gt;
You may also need to change the permissions of your user directory and your public_html directory to allow Apache to read and execute inside them.  To do this, run the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chmod o+x /home/myusername&lt;br /&gt;
$ sudo chmod o+rx /home/myusername/public_html&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, [[#Restarting Apache and Testing|restart Apache]].&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Remapping UserDir ===&lt;br /&gt;
&lt;br /&gt;
If you want to change the name of the UserDir web server root from '''public_html''' to something else like '''.html''', follow these instructions.  (You do not need to do this for the purposes of CSE 330; this serves as a reference.)&lt;br /&gt;
&lt;br /&gt;
# Rename your '''public_html''' to '''.html'''&lt;br /&gt;
#* The &amp;quot;.&amp;quot; in front of the directory name means that the directory is a hidden one.  You will not see it with the normal &amp;quot;ls&amp;quot; command.  Use &amp;quot;ls -a&amp;quot; to see hidden files as well.&lt;br /&gt;
# Edit the UserDir configuration file.&lt;br /&gt;
#* In RHEL, edit the master Apache configuration file at ''/etc/httpd/conf/httpd.conf''&lt;br /&gt;
#* In Debian, edit the UserDir configuration file at ''/etc/apache2/mods-available/userdir.conf''&lt;br /&gt;
# Find the line that reads &amp;lt;code&amp;gt;UserDir public_html&amp;lt;/code&amp;gt; and change it to &amp;lt;code&amp;gt;UserDir .html/&amp;lt;/code&amp;gt;&lt;br /&gt;
# [[#Restarting Apache and Testing|Restart Apache]].&lt;br /&gt;
&lt;br /&gt;
== Apache Logs ==&lt;br /&gt;
&lt;br /&gt;
Apache creates two log files: one for all access attempts to your server, and one for errors.  The locations of these log files are:&lt;br /&gt;
&lt;br /&gt;
* '''Debian:'''&lt;br /&gt;
** '''Access Log:''' /var/log/apache2/access.log&lt;br /&gt;
** '''Error Log:''' /var/log/apache2/error.log&lt;br /&gt;
* '''RHEL:'''&lt;br /&gt;
** '''Access Log:''' /var/log/httpd/access_log&lt;br /&gt;
** '''Error Log:''' /var/log/httpd/error_log&lt;br /&gt;
&lt;br /&gt;
You might find it helpful to see access and errors appear &amp;quot;live&amp;quot; in your terminal window as they are created.  To do this, you can use the [[Linux#Command Reference|tail -f]] command.  Since the log files have strict permissions, you will need to also use sudo.  Example on Debian:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo tail -f /var/log/apache2/error.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Hosts ==&lt;br /&gt;
&lt;br /&gt;
'''Virtual Hosts''' are used to run multiple Apache web servers from the same machine.  Virtual hosts can listen for connections on different ports and/or different hostnames, serving completely different web sites to each.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;VirtualHost cse330.dyndns.org&amp;gt;&lt;br /&gt;
	ServerAdmin webmaster@localhost&lt;br /&gt;
	ServerName cse330.dyndns.org&lt;br /&gt;
	DocumentRoot /home/www/cse330/&lt;br /&gt;
	ErrorLog /var/log/httpd/error_log&lt;br /&gt;
	LogLevel warn&lt;br /&gt;
	CustomLog /var/log/apache2/access_log combined&lt;br /&gt;
	ServerSignature On&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This configuration enables any requests that use a host name of ''cse330.dyndns.org'' will use ''/home/www/cse330'' as the root document directory.  Make sure that the DocumentRoot directory exists and is readable by the httpd process.  In RHEL, Apache runs as the '''apache''' user.  In Debian, it runs as the '''www-data''' user.&lt;br /&gt;
&lt;br /&gt;
It is good practice to put raw server configuration files in ''/etc/httpd/sites-available'' in RHEL or ''/etc/apache2/sites-available'' in Debian.  To activate a site, create a symlink from the configuration in ''sites-available'' to a sibling directory called ''sites-enabled''.  In Debian, these directories are already set up for you, and Debian Apache even provides the '''a2ensite''' and '''a2dissite''' commands to create or destroy the symlinks!  In RHEL, you have to do this by hand.&lt;br /&gt;
&lt;br /&gt;
== Restarting Apache and Testing ==&lt;br /&gt;
&lt;br /&gt;
Whenever you make changes to the Apache configuration files, you will need to restart Apache for the changes to take effect.  There are several different ways to restart Apache; they all functionally do (almost) the same thing, so choose your favorite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /usr/sbin/apachectl restart   # works on both Debian and RHEL&lt;br /&gt;
$ sudo apachectl restart    # if /usr/sbin is in your PATH (which it is by default in Debian, but not RHEL)&lt;br /&gt;
$ sudo /etc/init.d/httpd restart   # on RHEL&lt;br /&gt;
$ sudo /etc/init.d/apache2 restart   # on Debian&lt;br /&gt;
$ sudo /sbin/service httpd restart   # on RHEL&lt;br /&gt;
$ sudo /usr/sbin/service apache2 restart   # on Debian&lt;br /&gt;
$ sudo service httpd restart    # on RHEL&lt;br /&gt;
$ sudo service apache2 restart    # on Debian&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you're torn for which version is the &amp;quot;best&amp;quot; to use, the commands involving '''apachectl''' (think &amp;quot;Apache Control&amp;quot;) are written by the Apache folks themselves.  This has a couple advantages:&lt;br /&gt;
* They show you errors in the startup process (if there are any)&lt;br /&gt;
* They give you the option to perform a &amp;quot;soft&amp;quot; restart; that is, a restart that allows any pending connections to complete.  To perform a soft restart, use ''graceful'': &amp;lt;code&amp;gt;sudo apachectl graceful&amp;lt;/code&amp;gt;&lt;br /&gt;
In my anecdotal experience, the '''apachectl''' commands are also faster than the '''service''' or '''init.d''' commands.&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working, create a test file in your home directory under public_html, and then point your browser to it: http://ec2-xxx-xx-xx-xxx.compute-1.amazonaws.com/~yourUserName/hello.txt&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2168</id>
		<title>Module 1</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2168"/>
		<updated>2016-09-09T20:35:12Z</updated>

		<summary type="html">&lt;p&gt;Brian: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 1 introduces the fundamentals of HTML and CSS.  You will first make a static document using HTML and CSS, and then you will make a portal to a DuckDuckGo search.  This module is worth 50 points.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
&lt;br /&gt;
== Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Write a Birthday Card ===&lt;br /&gt;
&lt;br /&gt;
'''Write a birthday card to a friend or family member using HTML and CSS.'''  Use HTML to define the content of the card (like the headings and the paragraphs), and use CSS to define the appearance.  Some ideas:&lt;br /&gt;
&lt;br /&gt;
* Make the background-color of the page baby blue and use purple ink to write a card to a little boy&lt;br /&gt;
* Make the text big and include pictures of hearts&lt;br /&gt;
* Use a font with text shadows (more advanced)&lt;br /&gt;
&lt;br /&gt;
Use this opportunity to experiment with the plethora of CSS properties.  Remember that you're in a computer science class (not an art class), so we don't care if your card looks ugly.  The main thing is that you learn HTML and CSS and use them appropriately.&lt;br /&gt;
&lt;br /&gt;
==== How to Edit Your File ====&lt;br /&gt;
&lt;br /&gt;
Starting in Module 2, we will be using Komodo Edit as our primary development tool.  However, for the purposes of this exercise, we want you to edit your HTML file using a more basic text editor.&lt;br /&gt;
&lt;br /&gt;
* On Windows, consider Notepad++.  This is already installed for you in the CEC labs.  If you prefer to use your personal computer, you can download it from [http://notepad-plus-plus.org/ here].&lt;br /&gt;
* On Mac OS X, consider TextWrangler.  You can download it from [http://www.barebones.com/products/textwrangler/ here] or from the Apple App Store.&lt;br /&gt;
* Most Linux distributions come with gedit pre-installed, which you can use for this lab.&lt;br /&gt;
&lt;br /&gt;
Please save your file as ''birthday.html'' from the plain text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  What you need is a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// protocol.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validator with no errors.'''  From [http://validator.w3.org/ the validator], you can choose to upload your file.&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Sunday at 11:30 AM for Module 1). You are allowed to demo your assignment at TA office hours. However, after Sunday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a separate stylesheet and link your HTML file to it.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for the declared DOCTYPE (e.g., HTML 5) (10 points).&lt;br /&gt;
# '''Search Portal (10 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (10 points).&lt;br /&gt;
# '''Account Creation and Version Control (10 Points):'''&lt;br /&gt;
#* Account Created on Amazon Web Services (5 Points)&lt;br /&gt;
#* Bitbucket account created (2 Points)&lt;br /&gt;
#* Files pushed to properly named private repo (ex. Fall2016-Module1-FirstName-LastName-StudentID) on Bitbucket using Git (2 Points)&lt;br /&gt;
#* Bitbucket repo shared with cse330 user (1 Point)&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2154</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2154"/>
		<updated>2016-05-03T07:16:24Z</updated>

		<summary type="html">&lt;p&gt;Brian: Format new git ignore information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Git''' is a ''distributed version control system''.  It enables you to:&lt;br /&gt;
&lt;br /&gt;
# Keep track of revisions to your files&lt;br /&gt;
# Push and pull your revisions to other computers or servers&lt;br /&gt;
# Collaborate with other people on the same project&lt;br /&gt;
&lt;br /&gt;
Subversion is the version control system you used in CSE 132.  However, Subversion does not have the same agility of Git in terms of local revisions, staging, and collaboration.  This guide aims to get you up to speed with the power of Git for multi-developer projects.&lt;br /&gt;
&lt;br /&gt;
== Initializing Git ==&lt;br /&gt;
&lt;br /&gt;
To initialize a Git repository inside of a folder, you can use Git's '''init''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git init&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a .git directory, where Git will store information about the repository. This command can be run either in an empty folder, or in a folder where files already exist.&lt;br /&gt;
&lt;br /&gt;
== Local and Remote Branches ==&lt;br /&gt;
&lt;br /&gt;
When you create a branch named &amp;quot;mybranch&amp;quot; on your local repository and ''push'' changes up to the remote repository, they actually get pushed to a remote branch called '''origin/mybranch'''.  (Note that '''origin''' is the default name for a remote Git repository.)  Even after your collaborators ''pull'' changes from remote to their local repositories, no new branches are created on their own personal local repositories.&lt;br /&gt;
&lt;br /&gt;
Let's say that you and your partner are both working directly in the '''master''' branch (not a great idea for large or professional projects).  When you ''push'' your changes up, they get saved in '''origin/master'''.  When your partner goes and pulls changes from remote, if '''master''' is still her working copy, your changes will be immediately merged into her local '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
In practice, each collaborator will have their own branch, and when they make new versions of the features they are developing, they will merge those changes into '''master'''.  (When '''master''' changes, each collaborator will merge the changes from '''master''' back into their personal branch.)  What follows is an example that should help illustrate this process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding a Remote ==&lt;br /&gt;
A project that is being tracked with Git needs to be connected to a remote before files are pushed to version control. To add a remote to an initialized Git project, use the '''git remote add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;git remote add origin \&amp;lt;repository URL\&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin remote is the default server that Git will push to. &lt;br /&gt;
&lt;br /&gt;
== Staging ==&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Staging.jpg|400px|thumb|right|Staging a file in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Up to this point, you have been using SourceTree to automatically commit all changes.  However, Git enables you to not commit every single file if you don't want to.  This is where '''staging''' comes into play.&lt;br /&gt;
&lt;br /&gt;
To add a file to the stage, use the '''add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add &amp;lt;filename&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, when you run ''git commit'', only those files that have been staged will be updated.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' &amp;lt;code&amp;gt;git commit -a&amp;lt;/code&amp;gt; commits all files, whether or not they had been staged.  &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; (without the ''-a'') only commits those files in the staging area. It is a good idea to run '''git status''' before staging files to avoid staging files that should not be committed.&lt;br /&gt;
&lt;br /&gt;
=== Ignoring Files in Git  ===&lt;br /&gt;
Some files should not be committed to version control. Sensitive information such as SSH keys and files containing passwords should be ignored. Dependency folders such as node_modules should also be ignored; dependencies contain an enormous number of files that could change and will cause commit conflicts. . Rather, use the appropriate dependency manager to install those packages after cloning a repository (e.g. '''npm install'''). Folders containing virtual environments for frameworks such as Flask should also be ignored, and should instead be generated at will. &lt;br /&gt;
&lt;br /&gt;
To add files to be ignored, edit your .gitignore file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ vim .gitignore&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this file, add the file or folder to be ignored. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
node_modules&lt;br /&gt;
venv&lt;br /&gt;
db_connect.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging in SourceTree ===&lt;br /&gt;
&lt;br /&gt;
Staging in SourceTree is very intuitive.  However, before you can use this feature, you need to turn it on.  (We had you turn of the staging feature in Module 2.)&lt;br /&gt;
&lt;br /&gt;
# Go to the SourceTree preferences.&lt;br /&gt;
# Enter the Git pane.&lt;br /&gt;
# Check the box that says &amp;quot;Use the staging area&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should now be able to use the staging area!  In the &amp;quot;File Status View&amp;quot;, you can drag and drop files back and forth between Staged and Unstaged.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
== Commits ==&lt;br /&gt;
&lt;br /&gt;
When you want to create a &amp;quot;snapshot&amp;quot; of your project, what you do in Git is called a ''commit''.  The commit finds all files under version control, looks for ones that have been changed, and records the changes in a local archive.  You learned how to perform a commit in SourceTree [[Workflow|in Module 2]].&lt;br /&gt;
&lt;br /&gt;
If you need to determine what files have been changed since the last commit, you can use Git's '''status''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, the results of ''git status'' are displayed nicely in the &amp;quot;File Status View&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Branches and Merging ==&lt;br /&gt;
&lt;br /&gt;
Git enables you to work on different features of the same software suite in isolation from each other.  The way to do this is using '''branches'''.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Checkout.jpg|400px|thumb|right|Checking out an existing branch in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
To create a new branch, use the '''checkout -b''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b my-new-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, when you next commit, you will be committing to the '''my-new-branch''' branch rather than the default '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
To switch the working copy over to a different branch, use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the screenshot for how to checkout a branch in SourceTree.&lt;br /&gt;
&lt;br /&gt;
To merge changes from a different branch to the current working copy, use the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git merge my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you merge, if you wish to terminate a branch, use the '''branch -d''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git branch -d my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git also has another command called '''rebase''', which is similar to '''merge''' except that it combines the commits of each branch into a single branch, but still keeping the head of each branch.  For more information on ''rebase'', read [http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/ this article on the SourceTree blog].&lt;br /&gt;
&lt;br /&gt;
This will all make more sense when we go through an example.  We will also be using SourceTree in the example.&lt;br /&gt;
&lt;br /&gt;
== Example: Staging and Branches ==&lt;br /&gt;
&lt;br /&gt;
Suppose I have three files under version control: apple.txt, banana.txt, and carrot.txt.  The contents is like so (Thanks to [http://www.sumitkhemka.com/ Sumit Khemka] for the humor):&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' How do you make an apple turnover?  Push it downhill!&lt;br /&gt;
* '''banana.txt:''' What is a ghost's favorite fruit?  A boonanaa!&lt;br /&gt;
* '''carrot.txt:''' How do you make a soup rich?  Add 14 carats to it!&lt;br /&gt;
&lt;br /&gt;
All files have been committed to the HEAD, which is by default the '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A; git commit&lt;br /&gt;
...&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
nothing to commit, working directory clean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging ===&lt;br /&gt;
&lt;br /&gt;
Now, let's change the Apple joke, and keep the Banana and the Carrot the same:&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
&lt;br /&gt;
We can see in Git and SourceTree that there is one file changed: apple.txt.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Branching.jpg|400px|thumb|right|Creating a new branch using SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Let's go ahead and stage our file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add apple.txt&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, drag a file from the &amp;quot;working tree&amp;quot; pane to the &amp;quot;files staged in index&amp;quot; pane to stage the file.&lt;br /&gt;
&lt;br /&gt;
=== Branching ===&lt;br /&gt;
&lt;br /&gt;
But now, instead of committing this change directly to our '''master''' branch, let's make a new branch, and let's call it '''apple-branch'''.&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Branch&amp;quot; button to bring up a little dialog box.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
If we were using the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b apple-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is what we now see when we run '''git status''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch apple-branch&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's now go ahead and commit the changes:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ExampleAppleBranch.jpg|400px|thumb|right|Our current tree structure in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git commit -m &amp;quot;First Apple Commit&amp;quot;&lt;br /&gt;
[apple-branch c2c1738] First Apple Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, run the commit as you have been doing in Modules 2-4.&lt;br /&gt;
&lt;br /&gt;
Let's now make a second branch.  This branch is going to be rooted at the current version of the '''master''' branch, which of course is still the three original jokes.  To switch back to the '''master''' branch, we use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Checkout&amp;quot; button, and choose the revision or branch that you want to checkout; see the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
We will now make a revision to the Banana joke:&lt;br /&gt;
&lt;br /&gt;
* '''banana.txt:''' What would you call two bananas? A pair of slippers!&lt;br /&gt;
&lt;br /&gt;
Let's change the file, stage it, and see the current status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   banana.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will now create another new branch, and commit our changes to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout -b banana-branch&lt;br /&gt;
$ git commit -m &amp;quot;First Banana Commit&amp;quot;&lt;br /&gt;
[banana-branch f876aac] First Banana Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see all branches using '''git branch -v''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  apple-branch  c2c1738 First Apple Commit&lt;br /&gt;
* banana-branch f876aac First Banana Commit&lt;br /&gt;
  master        b770092 Initial Commit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this is where a GUI like SourceTree really comes in handy.  Here is what you now see in the Log View:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ViewBranches.jpg]]&lt;br /&gt;
&lt;br /&gt;
Nifty!&lt;br /&gt;
&lt;br /&gt;
=== Merging ===&lt;br /&gt;
&lt;br /&gt;
Okay, so now we want to take the two newest Apple and Banana jokes and merge them both back into '''master'''.  Let's first merge in '''banana-branch'''.  We can do this using the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
Updating b770092..f876aac&lt;br /&gt;
Fast-forward&lt;br /&gt;
 banana.txt | 2 +-&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''WHEN YOU MERGE, YOU TAKE THE CHANGES FROM THE SPECIFIED BRANCH AND MERGE THEM INTO THE CURRENT WORKING BRANCH.'''''  It is easy to get this mixed up.  Think of it this way: the currently &amp;quot;open&amp;quot; branch is the only one that will get changed when you perform the merge.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Merge.jpg|400px|thumb|right|Merging '''apple-branch''' into '''master''']]&lt;br /&gt;
&lt;br /&gt;
We now have the original Apple joke and the new Banana joke in the '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
Now let's merge in '''apple-branch'''.  We can use the command line to do it, but let's see how it works in SourceTree.  First press the &amp;quot;Merge&amp;quot; button in the toolbar.  You will see a window like the one shown in the screenshot to the right.  If everything looks good, press &amp;quot;OK&amp;quot; to perform the merge.&lt;br /&gt;
&lt;br /&gt;
We now have both of the new jokes in our '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat apple.txt &lt;br /&gt;
What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
$ cat banana.txt &lt;br /&gt;
What would you call two bananas? A pair of slippers!&lt;br /&gt;
$ cat carrot.txt &lt;br /&gt;
How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Okay, so we are now happy with our Apple joke.  Let's ''close'' that branch so that it doesn't show up in the list any more:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -d apple-branch&lt;br /&gt;
Deleted branch apple-branch (was c2c1738).&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  banana-branch f876aac First Banana Commit&lt;br /&gt;
* master        5159c4e Merge branch 'apple-branch'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's switch back to our banana branch, make a new joke, and commit that change to the banana branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
Switched to branch 'banana-branch'&lt;br /&gt;
$ echo 'What is the easiest way to make a banana split? Cut it in half!' &amp;gt; banana.txt&lt;br /&gt;
$ git commit -am 'Further revising our Banana joke'&lt;br /&gt;
[banana-branch cf6a894] Further revising our Banana joke&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that '''git commit -a''' is shorthand for '''git add -A''' followed by a plain '''git commit''' in most cases.&lt;br /&gt;
&lt;br /&gt;
But guess what: we changed our mind again!  Let's try an ''even better'' banana joke.  This time, I made the change using GUI tools:&lt;br /&gt;
&lt;br /&gt;
# Open '''banana.txt''' in your favorite text editor and make the joke say, &amp;quot;Why are bananas never lonely? Because they hang around in bunches!&amp;quot;&lt;br /&gt;
# In SourceTree, press &amp;quot;Commit&amp;quot; in the toolbar&lt;br /&gt;
# Drag the file to the &amp;quot;Stage&amp;quot; pane, type a commit message like &amp;quot;The best banana joke ever!&amp;quot;, and press &amp;quot;Commit&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Finally, let's merge our greatest Banana joke into '''master''' and close up '''banana-branch'''.  Here is how to do it in SourceTree:&lt;br /&gt;
&lt;br /&gt;
# Checkout '''master'''&lt;br /&gt;
# Press &amp;quot;Merge&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' and press &amp;quot;Merge&amp;quot;&lt;br /&gt;
# To delete the branch, press &amp;quot;Branch&amp;quot; and then &amp;quot;Delete Branch&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' only, press &amp;quot;Delete Branches&amp;quot;, and when asked to confirm, press &amp;quot;OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
We now have the three newest jokes in our '''master''' branch, and all other branches have been cleaned up.&lt;br /&gt;
&lt;br /&gt;
After performing all of the steps in this example, here is how the tree looks in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Tree.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Conflicts ==&lt;br /&gt;
&lt;br /&gt;
It might be the case that you inadvertently edit the same file on two different branches.  If you do, when you merge one branch into another, a '''merge conflict''' will occur.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Suppose both Apple and Banana change the Carrot joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Change the file in the Apple branch&lt;br /&gt;
$ git checkout apple-branch&lt;br /&gt;
	Switched to branch 'apple-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'What\'s a Vegetable\'s favourite martial art? Carrotee!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Apple changing carrot joke&amp;quot;&lt;br /&gt;
	[apple-branch f76f247] Apple changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Change the file in the Banana branch&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
	Switched to branch 'banana-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'Why did the carrot get an award? Because he was outstanding in his field!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Banana changing carrot joke&amp;quot;&lt;br /&gt;
	[banana-branch f565381] Banana changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Attempt to merge into master&lt;br /&gt;
$ git checkout master&lt;br /&gt;
	Switched to branch 'master'&lt;br /&gt;
$ git merge apple-branch&lt;br /&gt;
	Updating 7ed050b..f76f247&lt;br /&gt;
	Fast-forward&lt;br /&gt;
	 carrot.txt | 2 +-&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
	Auto-merging carrot.txt&lt;br /&gt;
	CONFLICT (content): Merge conflict in carrot.txt&lt;br /&gt;
	Automatic merge failed; fix conflicts and then commit the result.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yikes!  What do we do next?&lt;br /&gt;
&lt;br /&gt;
=== Resolving Merge Conflicts ===&lt;br /&gt;
&lt;br /&gt;
There are two main ways to resolve merge conflicts: by manually editing the file and choosing the lines of code you want to keep, or by choosing one version of the file and replacing the other entirely.&lt;br /&gt;
&lt;br /&gt;
==== Manually Editing the Conflicted File ====&lt;br /&gt;
&lt;br /&gt;
When you open the file after running &amp;lt;code&amp;gt;git merge banana-branch&amp;lt;/code&amp;gt; above, you will see something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;br /&gt;
What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
=======&lt;br /&gt;
Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; banana-branch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git added this notation to help you find which parts of the file were from the current branch (HEAD) and which ones were from the foreign branch (banana-branch).  Simply edit the file to reflect the version you prefer, and then commit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ emacs carrot.txt # edit the file to reflect the joke you want&lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 98ba901] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Keeping One Version and Replacing the Other ====&lt;br /&gt;
&lt;br /&gt;
Git provides commands that will merge a file from a branch.&lt;br /&gt;
&lt;br /&gt;
* If you want to keep the version in the current branch and ignore the version coming from the foreign branch, run &amp;lt;code&amp;gt;git checkout --ours carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* If you want to keep the version coming from the foreign branch and ignore the version in the current branch, run &amp;lt;code&amp;gt;git checkout --theirs carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep Banana's version of the joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --theirs carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1669536] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep the existing version of the joke, which is Apple's version since we had already merged Apple into master:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --ours carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1fdcd7b] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If you are using SourceTree, you can right-click the conflicted file in the file browser and select &amp;quot;keep mine&amp;quot; or &amp;quot;keep theirs&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Collaboration ==&lt;br /&gt;
&lt;br /&gt;
Using Git's powerful branch and merge tools are ideal for team collaboration.&lt;br /&gt;
&lt;br /&gt;
=== Collaboration Example ===&lt;br /&gt;
&lt;br /&gt;
Here's the idea: everyone working on a feature has their own branch.  Changes from each developer's branch are periodically merged in to the '''master''' branch, and developers periodically merge other people's changes from the '''master''' branch into their own branch.  When the feature is complete and bug-free, the branch is closed.&lt;br /&gt;
&lt;br /&gt;
Suppose there are three developers on a project: Susan, Caroline, and Rachel.  They each have their own branch and are developing separate features.  Susan is ready to merge her changes into '''master'''.  Here is what might happen:&lt;br /&gt;
&lt;br /&gt;
# Susan ''checks out'' the '''master''' branch locally.&lt;br /&gt;
# Susan ''pulls'' any changes that might be on '''origin/master''' into her local copy of '''master'''.&lt;br /&gt;
# Susan ''merges'' relevant changes from her branch into '''master'''.&lt;br /&gt;
# Susan ''checks out'' her own branch again.&lt;br /&gt;
# Susan ''pushes'' her repo updates to the remote repository.&lt;br /&gt;
# Caroline and Rachel ''check out'' the '''master''' branch locally.&lt;br /&gt;
# Caroline and Rachel ''pull'' the changes from '''origin/master''' to '''master'''.&lt;br /&gt;
# Caroline and Rachel ''check out'' their own branches locally.&lt;br /&gt;
# Caroline and Rachel ''merge'' '''master''' into their respective branches.&lt;br /&gt;
# Finally, Caroline and Rachel ''push'' everything up to the remote repository.&lt;br /&gt;
&lt;br /&gt;
This can be a cumbersome process, but it is important that you perform it at least once per working session to ensure that everyone's branches are up-to-date.&lt;br /&gt;
&lt;br /&gt;
=== Alternatives ===&lt;br /&gt;
&lt;br /&gt;
Fortunately for us, there exist developers who have created additional command-line utilities that automate the above process.  One such project is '''[https://github.com/aanand/git-up git-up]'''.  You and your partner may elect to use '''git-up''' instead of manual branching and merging.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2153</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2153"/>
		<updated>2016-05-03T07:15:02Z</updated>

		<summary type="html">&lt;p&gt;Brian: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Git''' is a ''distributed version control system''.  It enables you to:&lt;br /&gt;
&lt;br /&gt;
# Keep track of revisions to your files&lt;br /&gt;
# Push and pull your revisions to other computers or servers&lt;br /&gt;
# Collaborate with other people on the same project&lt;br /&gt;
&lt;br /&gt;
Subversion is the version control system you used in CSE 132.  However, Subversion does not have the same agility of Git in terms of local revisions, staging, and collaboration.  This guide aims to get you up to speed with the power of Git for multi-developer projects.&lt;br /&gt;
&lt;br /&gt;
== Initializing Git ==&lt;br /&gt;
&lt;br /&gt;
To initialize a Git repository inside of a folder, you can use Git's '''init''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git init&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a .git directory, where Git will store information about the repository. This command can be run either in an empty folder, or in a folder where files already exist.&lt;br /&gt;
&lt;br /&gt;
=== Local and Remote Branches ===&lt;br /&gt;
&lt;br /&gt;
When you create a branch named &amp;quot;mybranch&amp;quot; on your local repository and ''push'' changes up to the remote repository, they actually get pushed to a remote branch called '''origin/mybranch'''.  (Note that '''origin''' is the default name for a remote Git repository.)  Even after your collaborators ''pull'' changes from remote to their local repositories, no new branches are created on their own personal local repositories.&lt;br /&gt;
&lt;br /&gt;
Let's say that you and your partner are both working directly in the '''master''' branch (not a great idea for large or professional projects).  When you ''push'' your changes up, they get saved in '''origin/master'''.  When your partner goes and pulls changes from remote, if '''master''' is still her working copy, your changes will be immediately merged into her local '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
In practice, each collaborator will have their own branch, and when they make new versions of the features they are developing, they will merge those changes into '''master'''.  (When '''master''' changes, each collaborator will merge the changes from '''master''' back into their personal branch.)  What follows is an example that should help illustrate this process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Adding a Remote ===&lt;br /&gt;
A project that is being tracked with Git needs to be connected to a remote before files are pushed to version control. To add a remote to an initialized Git project, use the '''git remote add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;git remote add origin \&amp;lt;repository URL\&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin remote is the default server that Git will push to. &lt;br /&gt;
&lt;br /&gt;
== Staging ==&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Staging.jpg|400px|thumb|right|Staging a file in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Up to this point, you have been using SourceTree to automatically commit all changes.  However, Git enables you to not commit every single file if you don't want to.  This is where '''staging''' comes into play.&lt;br /&gt;
&lt;br /&gt;
To add a file to the stage, use the '''add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add &amp;lt;filename&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, when you run ''git commit'', only those files that have been staged will be updated.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' &amp;lt;code&amp;gt;git commit -a&amp;lt;/code&amp;gt; commits all files, whether or not they had been staged.  &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; (without the ''-a'') only commits those files in the staging area. It is a good idea to run '''git status''' before staging files to avoid staging files that should not be committed.&lt;br /&gt;
&lt;br /&gt;
=== Ignoring Files in Git  ===&lt;br /&gt;
Some files should not be committed to version control. Sensitive information such as SSH keys and files containing passwords should be ignored. Dependency folders such as node_modules should also be ignored; dependencies contain an enormous number of files that could change and will cause commit conflicts. . Rather, use the appropriate dependency manager to install those packages after cloning a repository (e.g. '''npm install'''). Folders containing virtual environments for frameworks such as Flask should also be ignored, and should instead be generated at will. &lt;br /&gt;
&lt;br /&gt;
To add files to be ignored, edit your .gitignore file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ vim .gitignore&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this file, add the file or folder to be ignored. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
node_modules&lt;br /&gt;
venv&lt;br /&gt;
db_connect.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging in SourceTree ===&lt;br /&gt;
&lt;br /&gt;
Staging in SourceTree is very intuitive.  However, before you can use this feature, you need to turn it on.  (We had you turn of the staging feature in Module 2.)&lt;br /&gt;
&lt;br /&gt;
# Go to the SourceTree preferences.&lt;br /&gt;
# Enter the Git pane.&lt;br /&gt;
# Check the box that says &amp;quot;Use the staging area&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should now be able to use the staging area!  In the &amp;quot;File Status View&amp;quot;, you can drag and drop files back and forth between Staged and Unstaged.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
== Commits ==&lt;br /&gt;
&lt;br /&gt;
When you want to create a &amp;quot;snapshot&amp;quot; of your project, what you do in Git is called a ''commit''.  The commit finds all files under version control, looks for ones that have been changed, and records the changes in a local archive.  You learned how to perform a commit in SourceTree [[Workflow|in Module 2]].&lt;br /&gt;
&lt;br /&gt;
If you need to determine what files have been changed since the last commit, you can use Git's '''status''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, the results of ''git status'' are displayed nicely in the &amp;quot;File Status View&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Branches and Merging ==&lt;br /&gt;
&lt;br /&gt;
Git enables you to work on different features of the same software suite in isolation from each other.  The way to do this is using '''branches'''.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Checkout.jpg|400px|thumb|right|Checking out an existing branch in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
To create a new branch, use the '''checkout -b''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b my-new-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, when you next commit, you will be committing to the '''my-new-branch''' branch rather than the default '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
To switch the working copy over to a different branch, use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the screenshot for how to checkout a branch in SourceTree.&lt;br /&gt;
&lt;br /&gt;
To merge changes from a different branch to the current working copy, use the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git merge my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you merge, if you wish to terminate a branch, use the '''branch -d''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git branch -d my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git also has another command called '''rebase''', which is similar to '''merge''' except that it combines the commits of each branch into a single branch, but still keeping the head of each branch.  For more information on ''rebase'', read [http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/ this article on the SourceTree blog].&lt;br /&gt;
&lt;br /&gt;
This will all make more sense when we go through an example.  We will also be using SourceTree in the example.&lt;br /&gt;
&lt;br /&gt;
== Example: Staging and Branches ==&lt;br /&gt;
&lt;br /&gt;
Suppose I have three files under version control: apple.txt, banana.txt, and carrot.txt.  The contents is like so (Thanks to [http://www.sumitkhemka.com/ Sumit Khemka] for the humor):&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' How do you make an apple turnover?  Push it downhill!&lt;br /&gt;
* '''banana.txt:''' What is a ghost's favorite fruit?  A boonanaa!&lt;br /&gt;
* '''carrot.txt:''' How do you make a soup rich?  Add 14 carats to it!&lt;br /&gt;
&lt;br /&gt;
All files have been committed to the HEAD, which is by default the '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A; git commit&lt;br /&gt;
...&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
nothing to commit, working directory clean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging ===&lt;br /&gt;
&lt;br /&gt;
Now, let's change the Apple joke, and keep the Banana and the Carrot the same:&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
&lt;br /&gt;
We can see in Git and SourceTree that there is one file changed: apple.txt.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Branching.jpg|400px|thumb|right|Creating a new branch using SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Let's go ahead and stage our file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add apple.txt&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, drag a file from the &amp;quot;working tree&amp;quot; pane to the &amp;quot;files staged in index&amp;quot; pane to stage the file.&lt;br /&gt;
&lt;br /&gt;
=== Branching ===&lt;br /&gt;
&lt;br /&gt;
But now, instead of committing this change directly to our '''master''' branch, let's make a new branch, and let's call it '''apple-branch'''.&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Branch&amp;quot; button to bring up a little dialog box.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
If we were using the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b apple-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is what we now see when we run '''git status''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch apple-branch&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's now go ahead and commit the changes:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ExampleAppleBranch.jpg|400px|thumb|right|Our current tree structure in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git commit -m &amp;quot;First Apple Commit&amp;quot;&lt;br /&gt;
[apple-branch c2c1738] First Apple Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, run the commit as you have been doing in Modules 2-4.&lt;br /&gt;
&lt;br /&gt;
Let's now make a second branch.  This branch is going to be rooted at the current version of the '''master''' branch, which of course is still the three original jokes.  To switch back to the '''master''' branch, we use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Checkout&amp;quot; button, and choose the revision or branch that you want to checkout; see the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
We will now make a revision to the Banana joke:&lt;br /&gt;
&lt;br /&gt;
* '''banana.txt:''' What would you call two bananas? A pair of slippers!&lt;br /&gt;
&lt;br /&gt;
Let's change the file, stage it, and see the current status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   banana.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will now create another new branch, and commit our changes to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout -b banana-branch&lt;br /&gt;
$ git commit -m &amp;quot;First Banana Commit&amp;quot;&lt;br /&gt;
[banana-branch f876aac] First Banana Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see all branches using '''git branch -v''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  apple-branch  c2c1738 First Apple Commit&lt;br /&gt;
* banana-branch f876aac First Banana Commit&lt;br /&gt;
  master        b770092 Initial Commit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this is where a GUI like SourceTree really comes in handy.  Here is what you now see in the Log View:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ViewBranches.jpg]]&lt;br /&gt;
&lt;br /&gt;
Nifty!&lt;br /&gt;
&lt;br /&gt;
=== Merging ===&lt;br /&gt;
&lt;br /&gt;
Okay, so now we want to take the two newest Apple and Banana jokes and merge them both back into '''master'''.  Let's first merge in '''banana-branch'''.  We can do this using the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
Updating b770092..f876aac&lt;br /&gt;
Fast-forward&lt;br /&gt;
 banana.txt | 2 +-&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''WHEN YOU MERGE, YOU TAKE THE CHANGES FROM THE SPECIFIED BRANCH AND MERGE THEM INTO THE CURRENT WORKING BRANCH.'''''  It is easy to get this mixed up.  Think of it this way: the currently &amp;quot;open&amp;quot; branch is the only one that will get changed when you perform the merge.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Merge.jpg|400px|thumb|right|Merging '''apple-branch''' into '''master''']]&lt;br /&gt;
&lt;br /&gt;
We now have the original Apple joke and the new Banana joke in the '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
Now let's merge in '''apple-branch'''.  We can use the command line to do it, but let's see how it works in SourceTree.  First press the &amp;quot;Merge&amp;quot; button in the toolbar.  You will see a window like the one shown in the screenshot to the right.  If everything looks good, press &amp;quot;OK&amp;quot; to perform the merge.&lt;br /&gt;
&lt;br /&gt;
We now have both of the new jokes in our '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat apple.txt &lt;br /&gt;
What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
$ cat banana.txt &lt;br /&gt;
What would you call two bananas? A pair of slippers!&lt;br /&gt;
$ cat carrot.txt &lt;br /&gt;
How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Okay, so we are now happy with our Apple joke.  Let's ''close'' that branch so that it doesn't show up in the list any more:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -d apple-branch&lt;br /&gt;
Deleted branch apple-branch (was c2c1738).&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  banana-branch f876aac First Banana Commit&lt;br /&gt;
* master        5159c4e Merge branch 'apple-branch'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's switch back to our banana branch, make a new joke, and commit that change to the banana branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
Switched to branch 'banana-branch'&lt;br /&gt;
$ echo 'What is the easiest way to make a banana split? Cut it in half!' &amp;gt; banana.txt&lt;br /&gt;
$ git commit -am 'Further revising our Banana joke'&lt;br /&gt;
[banana-branch cf6a894] Further revising our Banana joke&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that '''git commit -a''' is shorthand for '''git add -A''' followed by a plain '''git commit''' in most cases.&lt;br /&gt;
&lt;br /&gt;
But guess what: we changed our mind again!  Let's try an ''even better'' banana joke.  This time, I made the change using GUI tools:&lt;br /&gt;
&lt;br /&gt;
# Open '''banana.txt''' in your favorite text editor and make the joke say, &amp;quot;Why are bananas never lonely? Because they hang around in bunches!&amp;quot;&lt;br /&gt;
# In SourceTree, press &amp;quot;Commit&amp;quot; in the toolbar&lt;br /&gt;
# Drag the file to the &amp;quot;Stage&amp;quot; pane, type a commit message like &amp;quot;The best banana joke ever!&amp;quot;, and press &amp;quot;Commit&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Finally, let's merge our greatest Banana joke into '''master''' and close up '''banana-branch'''.  Here is how to do it in SourceTree:&lt;br /&gt;
&lt;br /&gt;
# Checkout '''master'''&lt;br /&gt;
# Press &amp;quot;Merge&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' and press &amp;quot;Merge&amp;quot;&lt;br /&gt;
# To delete the branch, press &amp;quot;Branch&amp;quot; and then &amp;quot;Delete Branch&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' only, press &amp;quot;Delete Branches&amp;quot;, and when asked to confirm, press &amp;quot;OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
We now have the three newest jokes in our '''master''' branch, and all other branches have been cleaned up.&lt;br /&gt;
&lt;br /&gt;
After performing all of the steps in this example, here is how the tree looks in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Tree.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Conflicts ==&lt;br /&gt;
&lt;br /&gt;
It might be the case that you inadvertently edit the same file on two different branches.  If you do, when you merge one branch into another, a '''merge conflict''' will occur.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Suppose both Apple and Banana change the Carrot joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Change the file in the Apple branch&lt;br /&gt;
$ git checkout apple-branch&lt;br /&gt;
	Switched to branch 'apple-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'What\'s a Vegetable\'s favourite martial art? Carrotee!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Apple changing carrot joke&amp;quot;&lt;br /&gt;
	[apple-branch f76f247] Apple changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Change the file in the Banana branch&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
	Switched to branch 'banana-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'Why did the carrot get an award? Because he was outstanding in his field!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Banana changing carrot joke&amp;quot;&lt;br /&gt;
	[banana-branch f565381] Banana changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Attempt to merge into master&lt;br /&gt;
$ git checkout master&lt;br /&gt;
	Switched to branch 'master'&lt;br /&gt;
$ git merge apple-branch&lt;br /&gt;
	Updating 7ed050b..f76f247&lt;br /&gt;
	Fast-forward&lt;br /&gt;
	 carrot.txt | 2 +-&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
	Auto-merging carrot.txt&lt;br /&gt;
	CONFLICT (content): Merge conflict in carrot.txt&lt;br /&gt;
	Automatic merge failed; fix conflicts and then commit the result.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yikes!  What do we do next?&lt;br /&gt;
&lt;br /&gt;
=== Resolving Merge Conflicts ===&lt;br /&gt;
&lt;br /&gt;
There are two main ways to resolve merge conflicts: by manually editing the file and choosing the lines of code you want to keep, or by choosing one version of the file and replacing the other entirely.&lt;br /&gt;
&lt;br /&gt;
==== Manually Editing the Conflicted File ====&lt;br /&gt;
&lt;br /&gt;
When you open the file after running &amp;lt;code&amp;gt;git merge banana-branch&amp;lt;/code&amp;gt; above, you will see something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;br /&gt;
What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
=======&lt;br /&gt;
Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; banana-branch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git added this notation to help you find which parts of the file were from the current branch (HEAD) and which ones were from the foreign branch (banana-branch).  Simply edit the file to reflect the version you prefer, and then commit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ emacs carrot.txt # edit the file to reflect the joke you want&lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 98ba901] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Keeping One Version and Replacing the Other ====&lt;br /&gt;
&lt;br /&gt;
Git provides commands that will merge a file from a branch.&lt;br /&gt;
&lt;br /&gt;
* If you want to keep the version in the current branch and ignore the version coming from the foreign branch, run &amp;lt;code&amp;gt;git checkout --ours carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* If you want to keep the version coming from the foreign branch and ignore the version in the current branch, run &amp;lt;code&amp;gt;git checkout --theirs carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep Banana's version of the joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --theirs carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1669536] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep the existing version of the joke, which is Apple's version since we had already merged Apple into master:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --ours carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1fdcd7b] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If you are using SourceTree, you can right-click the conflicted file in the file browser and select &amp;quot;keep mine&amp;quot; or &amp;quot;keep theirs&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Collaboration ==&lt;br /&gt;
&lt;br /&gt;
Using Git's powerful branch and merge tools are ideal for team collaboration.&lt;br /&gt;
&lt;br /&gt;
=== Collaboration Example ===&lt;br /&gt;
&lt;br /&gt;
Here's the idea: everyone working on a feature has their own branch.  Changes from each developer's branch are periodically merged in to the '''master''' branch, and developers periodically merge other people's changes from the '''master''' branch into their own branch.  When the feature is complete and bug-free, the branch is closed.&lt;br /&gt;
&lt;br /&gt;
Suppose there are three developers on a project: Susan, Caroline, and Rachel.  They each have their own branch and are developing separate features.  Susan is ready to merge her changes into '''master'''.  Here is what might happen:&lt;br /&gt;
&lt;br /&gt;
# Susan ''checks out'' the '''master''' branch locally.&lt;br /&gt;
# Susan ''pulls'' any changes that might be on '''origin/master''' into her local copy of '''master'''.&lt;br /&gt;
# Susan ''merges'' relevant changes from her branch into '''master'''.&lt;br /&gt;
# Susan ''checks out'' her own branch again.&lt;br /&gt;
# Susan ''pushes'' her repo updates to the remote repository.&lt;br /&gt;
# Caroline and Rachel ''check out'' the '''master''' branch locally.&lt;br /&gt;
# Caroline and Rachel ''pull'' the changes from '''origin/master''' to '''master'''.&lt;br /&gt;
# Caroline and Rachel ''check out'' their own branches locally.&lt;br /&gt;
# Caroline and Rachel ''merge'' '''master''' into their respective branches.&lt;br /&gt;
# Finally, Caroline and Rachel ''push'' everything up to the remote repository.&lt;br /&gt;
&lt;br /&gt;
This can be a cumbersome process, but it is important that you perform it at least once per working session to ensure that everyone's branches are up-to-date.&lt;br /&gt;
&lt;br /&gt;
=== Alternatives ===&lt;br /&gt;
&lt;br /&gt;
Fortunately for us, there exist developers who have created additional command-line utilities that automate the above process.  One such project is '''[https://github.com/aanand/git-up git-up]'''.  You and your partner may elect to use '''git-up''' instead of manual branching and merging.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>Brian</name></author>
		
	</entry>
</feed>