So you finished some code and you want to show the world….now what?
According to the GitHub site: “GitHub Pages are public webpages freely hosted and easily published through our site”.
You can access GitHub through the command line of your terminal (Mac).
Why would I want to commit a file to GitHub?
GitHub provides a snapshot of your work at all stages of production. This can prove useful when multiple people are working on the same project, or if you need to view files at a certain point in time. You can make commits as often as you would like, network or no network.
This tutorial is for the steps after you set up GitHub, fork a desirable repository (if applicable), and clone the desired repository in your directory (if applicable). See the link below to get you started.
When you are ready to commit code to GitHub, do the following:
Open your terminal. This can be accomplished on a Mac by pressing command + space bar. This will open a Spotlight search bar. Type “terminal” then press enter. The screen should look similar to the screen below:
Next, ensure you are in the correct folder. Check the folder by entering “pwd” in your terminal. If you’re not in the correct folder, you can enter “cd ..” into your terminal to move up directories, and “cd” followed by the desired folder name to toggle into folders. The “ls” command provides a list of folders/files within the path you’re currently in. Once you confirm you’re in the desired folder, you can check the git details through the “git status” command. Here you can view whether your branch is up-to-date or if you have unsaved code to commit. Confirm you have the correct git repository by entering “git remote -v”. This will provide you with your current git repository path. Details below:
[18:30:02] (master) apples-and-holidays-ruby-007 YOUR CURRENT BRANCH/FOLDER
♥ git remote -v GIT COMMAND TO CONFIRM REPOSITORY
origin firstname.lastname@example.org:Casie/apples-and-holidays-ruby-007.git (fetch)
origin email@example.com:Casie/apples-and-holidays-ruby-007.git (push)
Next, enter the command “git commit -am “YOUR MESSAGE” “. This command performs many functions: it adds your staged file (the intermediary phase between working and committing files), commits the file, and provides a message tag along with the file when it is pushed to your GitHub repository. Write detailed comments, as this will come in handy to stay organized when pushing through many commits.
You have now successfully committed a file to GitHub!