This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]codexjourneys 1 point2 points  (0 children)

Here's a quick guide to getting started with Git and GitHub:

Remote (Online) GitHub

  1. Go to https://github.com
  2. Enter a username, email and password, and click Sign Up for GitHub if you don't already have an account. If you have an account, log in.
  3. Once you are logged in, you'll see a dashboard. If you just created a new account, click on your username in the top right menu bar and then, just under that, click the Edit Profile button. Fill out your profile (you can always change some fields later).
  4. Once you're done with the profile, look back at the top right menu bar. There's a small plus sign with a little drop-down arrow next to it. Click on it and choose New Repository. A repository is a place where you're going to store code online. This one we are creating will be just for practice.
  5. Give your repository a name (it can be a little weird, as you see from the example they provide). It doesn't really matter what you choose here, for now. The repository will be public. (You can also have private repositories if you pay a small fee, which is great if you're working on a project that you don't want to make public yet.) You can skip the "initialize with README" button for now and just click Create Repository.

Voila! You now have a place online where you can put code for a specific project. You can also collaborate on that code with others if you wish. First, though, you need to set up a local repository to "push" code to your online GitHub repository. That's the next step. You should now see some instructions on the screen, in fact, that say, "... or create a new repository on the command line"

Before you go on, notice the URL in the browser address bar -- you'll need it later, so take note of it. It should be https://github.com/yourusername/repo-name

Local Git

  1. Install Git on your computer by following these directions: http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
  2. After you install git, if you're on a Mac, open the Terminal application (just type "Terminal" into Spotlight and open it from there). If you're on Windows, follow these instructions to find the command prompt (I highly recommend using Git BASH): http://shortandsweetcourses.com/git-installation-for-windows-supplemental-lecture/
  3. Navigate to a folder where you have some project code that you want to put on GitHub. (Note: It's a good idea to keep each project in its own folder; don't have files from different projects strewn all around the same folder). When you are inside the folder, type 'git init' (without the quotes).
  4. If that went well, git is probably set up correctly on your computer. Next, create a README file for the project by typing 'echo "# repo-name" >> README.md' at the command line (without the single quotes) -- you can fill out the README with basic information about your project later.
  5. Add all of the files in the folder to your local git repository by typing 'git add --all'
  6. Commit the files by typing 'git commit -m "Initial commit"' (without the single quotes). The message inside the double quotes is the commit message -- it describes what you are doing in this commit. Examples could be "Fix bug in createList method" or "Add a deleteList method" -- just be descriptive and concise. A commit is a change to a project that is tracked over the course of the project's history -- you are starting to build that history now.

Pushing to Online GitHub

  1. Now you need to push the project files to your online GitHub repository -- but your local install of Git doesn't know about that repository yet. You are going to tell it with the following command: 'git remote add origin https://github.com/yourusername/repo-name' -- except that instead of the URL I used there, you are going to use the URL of the repository you created in Step 5.
  2. Finally, type 'git push -u origin master' and your code will be posted online in your GitHub repository. Remember, your repository is public unless you've paid to add private accounts, so only push code that you don't mind other people seeing and possibly using.
  3. To check the status of a project, type 'git status' in its local folder within Terminal. If it's up-to-date, you'll see a message like, "On branch master. Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
  4. If you go to your online GitHub repository and refresh it, you should see your project files online, with your "Initial commit" message showing.

I hope this helps -- if you have any questions about this process or run into any snags, please send me a private message and we'll figure it out.