In this part of the assignment you will learn some basics of git and will start to use terminal.
First, you need to create a directory that you will use for the course. In your VM type the following:
$ mkdir cse320
This will create a directory named "cse320" in your current directory. Hint: to find the current working directory you can type: pwd
, which shows full path and you always can use full path, while navigating through the folders.
Then you need to enter into this directory by typing the following command in the terminal:
$ cd cse320
Now we are ready to clone our repository. To do that you need to type the following:
$ git clone https://github.com/cse320spring2019/hw0-<your GitHub username>
It may ask you for your username and password for the GitHub. If you want to avoid typing your login/password every time you can setup SSH keys (it is easy to google how to do so). Now, as you have successfully cloned your repository you need to enter it using already familiar command:
$ cd hw0-<your GitHub username>
Now, let's get familiar with Travis CI interface that is used for providing feedback in our course. Type the following:
$ mv hello.a hello.b
This will rename hello.a
file to hello.b
. As we made a change to our repository a version control system (git in our case) should notice that! Let's check that by typing the following command:
$ git status
You can see that one file is deleted and one file is added. We are fine with that as this is what we just had done. So let's say to the git that we want these changes to be staged:
$ git add .
This '.' means that we want to add all changes (i.e., all files) that were done. Now we need to commit these changes, i.e. say to git that we want to create a check point at this state:
$ git commit -m "My first commit"
"-m" flag indicates that you include the message for commit right after that flag. Most likely, git will issue an error saying that you should configure it with your credentials such as name and email. Let's do that by typing the following commands (I will use my credentials but you should use yours) and then try again to commit our changes:
$ git config user.email "smadaminov@cs.stonybrook.edu"
$ git config user.name "Sergey Madaminov"
$ git commit -m "My first commit"
Now, it should work and we are ready to push our changes to the GitHub server. This is important to do as changes are stored locally in your VM unless you push them to the GitHub server. If anything will happen to your VM (chances are high that it may happen around the submission deadline) then you might loose all your work! So please commit and push your changes more often rather then rarely! Anyway, let's finally push our changes to the GitHub server:
$ git push
Now, let's see results. Open the link https://github.com/cse320spring2019/hw0-<your GitHub username> and click on the link to see your commits (it usually has name "X commits", where X is some number and there is a timer icon just left to it). You should see list of commits in your repository. There will be more than one, which is fine as first few are made by us during creation of this assignment. On top you should see yours. But, wait...there is a red cross icon indicating that something went wrong. This is a notification from Travis CI saying that something went wrong. Let's click on it to see what exactly. NB: be aware that it may take some time to generate a page with report so if you will get any error such as that repository/owner cannot be found just be patient and try again in a few minutes. After some time, link should lead you to the report and you can scroll down to see something like that:
$ gcc hello.c -o hello
gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Oh no! We did a mistake during renaming of our file. Let's quickly fix it:
$ mv hello.b hello.c
$ git add .
$ git commit -m "rename fix"
$ git push
Now, let's check again our commit and we should see a green tick that indicates that now our submission passed pre-defined test. If we will click on the tick we should be able to see a report that will contain no errors. Finally, we are done!
Congratulations! That concludes first home work.
Please note that it is normal if you don't see red cross/green tick. Assignment will be finished once you push all commits from the instruction. As I have to manually enable Travis CI for each of you and I can do that only after repository is created, it is possible that you had tried to push code and Travis CI was not enabled yet. I will go through this tool in more details in the upcoming lectures.