Working with the Git Worflow

Git is the most adopted version control system out there for software development. Git keeps track of changes made to a file over time and allows for access to those changes to anyone who has the link, unless you upgrade to a paid plan which allows you to have private access repositories. The workflow for using Git has three distinct steps: modifying files, staging those files and committing them. Let’s walk through the process of creating and modifying a file using Git.

I’ll assume you have used the Git tutorial to set up Git on your machine and have opened an account.

Create a practice directory and go into that directory in your terminal.

Image

Next, create a git repository in your directory with: git init

Image

Now we can create a file in the directory.

Image

That was our first step in the workflow, modifying files (in this case, creating a file)

Next, we can select this file or “stage” it to be added to our repository as an edit.

Image

At any time, you can find out the status of where you are in the Git workflow with the command: git status

Image

The above message, from git status, is telling us that we have a change to be committed and that the change is the a new file created called README.

At this point we have made the file, staged it and are now ready to commit it. To commit the file, we enter the command: git commit -m ‘a comment about the change that was made’

Image

 

The git commit command commits any changes that have been staged. There may be other changes that have not been staged yet, and those changes will not be committed until they are staged. This highlights the purpose of the staging part of the workflow. You may have changes that have been made but are not ready to commit, then you have to go to another file and make changes and commit them before the previous file you were working on is finished and ready to commit. Whichever changes you do want to commit, stage those files only, then commit them.

Aside

In my homework for class this week at DaVinci Coders, we were to play with a calculator using variables. I chose to create a function that would define how many slices of pizza are in one pizza, how many slices each person would receive and how many people would be present. The output, then, printed how many pizzas would need to be ordered.

The code read as follows:

pizza_code

What I discovered is that my original code returned an incorrect value because I did not make the integers floating, my answer returned that 4 pizzas would be needed, but that would only be 32 slices and 34 slices were needed total. So I would need 4 whole pizzas and a portion of another. Once I made the integers floating, my answer returned 4.25 pizzas, which is technically correct, but since one cannot order .25 of a pizza, I wanted my answer to round up to the nearest whole number. I found that I could do this by adding .ceil to my answer. Finally, my output gave 5 pizzas, which was the answer I was looking for.

pizza_output

 

Ruby Podcasts

I found some useful podcasts to listen to on my way-longer-than-it-should-be-due-to-stupid-traffic commute. The first is “Learning Rails”. I especially enjoyed the first podcast (#1) called, “Why You Should Learn Ruby on Rails” which explained what Ruby and Rails are and how they compare and improve on earlier languages. It makes an argument to developers to spend the time learning Ruby on Rails. It made me appreciate that this the language that this bootcamp focuses on. I’m excited to learn Ruby and Rails. 

The second podcast I enjoyed was “The Hansel Minutes”. I enjoyed a podcast called, “What it really means to be a Junior Developer with Jonathan Barronville.” I’ve been wondering about what really makes someone a Junior or Senior developer. This podcast nicely focused on the importance of continued and lifelong learning as what is important instead of how long you’ve been programming or how many languages you know, etc. This is one of the things I really appreciate about the programming world — you must be a lifelong learner and be willing to always learn something new in order to excel in this field.