Skip to content

Latest commit

 

History

History
72 lines (39 loc) · 4.76 KB

gitTutorial.md

File metadata and controls

72 lines (39 loc) · 4.76 KB

Introduction

The following is a revised version of the git and GitHub tutorial. You can still access the old git tutorial and list of basic git commands. However, everything you need to get started with git (other than installation) is included in this tutorial.

Installion and Setup

You can (and should) use the new gitWindows or gitApple tutorials to install and set up git on your computer.

How to use git

A git repository exists both on GitHub (online) and on your local machine. It can also exist on machines other than yours (e.g., a project collaborator), but we will ignore that possiblity for the moment.

The key to successfully working with git is navigating the relationship between the local copy and the GitHub copy. This relationship is summarized by the concepts of pushing and pulling.

Pulling and Pushing

  1. Pulling is when you take a file that you added or edited on GitHub and sync it with your local machine.
  2. Pushing is when you take a file that you added or edited to your local machine and sync it with GitHub.

The primary issue then for you, as a git user, is whether you (1) want to add and edit files on the GitHub website, and only sync to your computer after the fact or (2) want to add and edit your computer and only sync (upload) your files to GitHub after the fact. I discuss the first scenario in the Working from GitHub First section and the latter scenario in the Local Machine First section.

Importantly, you ideally do NOT want to do both when you are first starting out. Choose one of the two workflows and stick with it until you are more advanced. Either GitHub First or Local Machine First.

Working from GitHub First

Step 1: Navigate to your repository on the GitHub website.

Step 2: Create a new file

Step 3: Write your answers in the new file. Scroll down to the bottom of the page and click the Commit changes button

Step 4: Now that you have successfully commited your file to GitHub, you need to sync the file with your local machine. To do this you need to open terminal, and move to the folder using the cd command. Revisit either the gitWindows or gitApple tutorials if you do not remember how to do this.

Step 5: Then use the ````git pull``` command.

Step 6: Your files are now synced, and you will now see the file you uploaded on GitHub downloaded to your computer and in the repository folder. You are done! DONE!

Local Machine First

Step 1: Write your answers down in a text editor (e.g., sublime text) and save them to your computer repository.

Step 2: Open terminal and move to the folder using the cd command.

Step 3: Type the following three commands into terminal. Substitute any message in the " " that you want associated with the file. GitHub requires that you leave a message of some kind. This could be something as simple as "Upload" or "New File" or "Screw You GitHub I don't want to leave a message".

git add .
git commit -m "Your Message"
git push

Step 4: You are done! DONE! You will now see the file online in your GitHub Repository. Repeat Steps 2-3 if you make any changes to the file on your local machine and want them uploaded to GitHub.

Trouble Shooting

If you still have problems either with installing or using git, you can access this additional file on troubleshooting git. If the tips in that file also do not work, please do not hesitate to contact me.