Welcome to Challenge 4 of the Github and Website Workshop - using git to keep track of your changes and update your online website!
Recall: Git is a revision control system, a tool to manage the history of your code (the tool we are learning to use in the terminal today)
Let's take a look at the history of the code we've written so far!
Open git shell and navigate to the folder with your project (if it isn't already open). Recall the following commands:
- pwd: prints the current file path e.g. Documents/CS/
- ls: prints the contents of the current folder
- cd [folder]: enters the folder
Add files and commit
Read about the following commands on http://gitref.org/basic/
- git add
- git status
- git diff
- git commit
- (the other commands won't be discussed in this workshop)
Enter the commands from this tutorial as you go, but use file names from your own repository.
Note: your commit message does NOT have to be as long as it says in the tutorial. You can just type git commit -m “commit message here”, but with a short (a few words) commit message that actually describes what you just did.
Once you have entered these commands, you should have committed all your files, and running git status should give the message that your working directory is clean (no new changes).
Push your changes
Right now you have made some commits - but no one else can see these changes yet. To have them show up on GIthub, you need to "push" your code.
First let's discuss a few concepts related to this push command:
- You are putting changes from your computer to the remote server. Usually the remote server, the place on Github where your files can be viewed, is called origin.
- There is a concept called branching in git which lets you work on multiple changes at the same time. We will not be talking about branches in this workshop, but it helps to know that the branch you are working on is called master - the master branch (ruler of them all)
- To send all your changes to the master branch on the remote server, type git push origin master. It's possible that the first time you do this git will ask you for some more information. If this happens please let a mentor know and we'll help you out!
Now go to the repository on Github.com and take a look at your changes there!
If you ever want to review git commands and what they do, check out this reference sheet