Pssst, I'm going to ask for feedback at the end
Version control is useful in many cases (some people are even tracking law changes using Git!)
And, last but not least:
Well, let's see an example of versioning:
I need to add an image to that website...
GitHub
Google Doc
A repository is where you store your code on GitHub, along with all its version.
Technically, not only on GitHub: the code you have locally is ALSO a repository, a "clone" of the one that's on GitHub.
A commit is a set of changes on one or more files. It also has:
We will create a new repository with a couple of commits, and publish it to GitHub
Good. A bit more theory, then!
On the top right corner of every GitHub repository, you can create a Fork of any repository.
This will copy the whole repository, and you will own that copy.
It is very common in Open Source world to create a pull request from a fork into the original repository, so that the original owners don't have to add too many people to the collaborator list.
It's also a backup if the original owner decide to delete their repository.
A pull request is a request to "merge" a change into the main project.
The person owning the repository will have the choice of accepting or refusing the change.
It can be done in the same repository, using different branches, or across forks.
A branch helps to work in parallel with multiple people, or simply to work on multiple features in parallel.
Here you can see that the "carousel" branch was done in parallel of the rest of the work, done directly in master.
A merge is used to get the changes from one branch into another one.
Here you can see 2 merge commits: the 1st one is on the Carousel branch, to get the landing page changes from Master.
The second merge commit is to get the carousel into Master. This was done via a Pull Request (PR)
I know I know, the previous slides might be confusing.
Rejoice, it's again time for some EXERCISES!
Here you should work in pair, as you need to learn both sides (being the owner of the main repository & being a collaborator)
Hints: <link rel="stylesheet" href="css/style.css" />
<a href="index.html" title="homepage">Homepage</a>
The collaborator is in charge of adding navigation between all pages; this will be done by creating a menu of each of them.
This time let's split up - collaborator & owner can work separately
Hints: in css/style.css
body {background-image: url(...);}
You can solve it on the Collaborator side by updating your local branch (branches -> merge into current branch -> upstream/master)
It will show a warning, proceed anyway. It should then show you something like this:
If you now open the file in Atom, it'll let you choose which version you want to use. Pick one, and got back to your GitHub app.
You should know be able to commit & push again. The PR merge button should now be available for the owner.
As a nice side thing, GitHub also allow you to host your webpages on its website. Here's how to do it:
In the setting tab of your repo on GitHub.com, you should see something like this. Set the "source" as your master branch - your website will be available in a few seconds at a URL like this: https://<username>.github.io/<repo-name>/.
When you want to remember a particular commit as a point of reference, e.g. when you release your website the 1st time, you can create a "tag", or a release on GitHub.
You cannot do that through the app, but in the website you will find a tab under the repo name.
All changes have a date! And even a description, an author, ...
Use latest release (tag), or start from one of the branches - usually master
Merging is easy! Just update from GitHub, or push a pull request.
Resources