Change, Commit, Push (a Text file)

The goals for this exercise are to

  1. Change a file, save the file into git, and then upload those changes back to your copy of the project on GitHub

  2. For this exercise we'll use a text file because we don't compile or run text files.  In other words, we can't mess up our program nor get any compile-time errors since the file isn't C# source code.

What you need to do to prepare for this exercise:


NOTE: It's possible that Visual Studio will move the following features back to the Team Explorer panel.  If that happens you can find a version of these instructions for Team Explorer here.

 

For this exercise make sure that you have Visual Studio open.  Within Visual Studio make sure that you have the 'Solution Explorer' open.  If it's not open you can show it using the View -> Solution Explorer menu item.

Within the Solution Explorer double-click on the 'Poetry.txt' file.

Add a new line of poetry to the end of the file.  Anything that's 'safe for work' is fine.

Save the file using the File -> Save menu item, like you normally do.

Note that right now, after you've saved the file but before you've committed the changes to git, the change you just made is saved in the Poetry.txt file on your hard drive BUT it has not yet been saved into git (nor into GitHub).

You can commit your change(s) by opening up the Git Changes window, using the View -> Git Changes menu item. (Note: This is under the View menu, and NOT under the Git menu)

Once you've opened the panel you should next open the item labeled "Changes", so that it shows you what's changed since your last commit (and gives you the option of committing your current changes):

As you can see in the above picture, the file 'Poetry.txt' list listed in the Git Changes panel, under the 'Changes' section.  If you double click on that file Visua Studio will show you the difference between the current version of the file and the last version that was saved into git, side by side.  It'll even highlight the lines that have changed.

After trying that out you should click on the box labeled "Enter a commit message..." and fill in a quick, one-line summary of the change you just made.  Something like "Added a line of poetry to the end of the file" might be good.

Once you've entered a commit message you can click on the 'commit all' button to save your changes into git.  It's worth noting that you cannot commit until you type in a message - Visual Studio will literally 'gray out' the button so that you can't click on it.  Make sure that you include a commit message!!

However, you've only saved the changes ("committed the changes") into your git repo on your local computer.  You have NOT yet uploaded your changes to your account on GitHub.  In order to upload your changes to GitHub we're going to have to push the changes up to GitHub.

In the Git Changes panel look for the 'up arrow' icon at the top-right and click on it to push your latest, committed changes:
(You can also click on the little triangle pointing down to open up a couple more options, as pictured below, but you still want the 'Push' option)

After a short(-ish) delay the changes will be pushed to GitHub.

You can confirm that the push worked by opening up that same page in your browser and the clicking on the phrase '2 Commits':

On the page that appears you should see your latest commit (changes) listed.  You can click on it to see the changes in detail.

How to double-check that you've handed in the correct files

At this point you should return to the main page for your repo, on GitHub:

Your repo's main page

At this point you should confirm that you're seeing your changes in your files on GitHub.

Right now we've only changed Poetry.txt, so click on that and you should see something like:

Current contents of Poetry.txt

 

Notice that we can see the stuff that we added (in our case, it's the 'sdfasdfsdfsdafasfsadfsadfsadfasdfsadfsadfsfd' at the bottom of the file which confirms that we've successfully uploaded the correct file and that we (and the instructor!) can see the changes we've made.

If you DON'T see the changes: please go back and try the instructions again making sure to following along in detail.  If that doesn't work please ask for help.  Please start by asking other students, and if that doesn't work then definitely seek out help from the instructor (and tutor, if there's a BIT tutor this quarter)

 

What you need to do for this exercise
  1. Add a line to the end of the Poetry.txt file and save the file.
  2. Commit your changes to your local git repo
  3. Push your changes to your account in GitHub