Author Topic: How 2 Github  (Read 7122 times)

Offline CommunistPancake

  • New Foal
  • *
  • Posts: 5
  • That C# guy
    • Blog
How 2 Github
« on: 2012-September 29, 06:02:24 »
Git is a version control system. If you're not a programmer, you probably don't know what that means. Basically, it's file hosting meant for code. Every time you "commit" a version, you now have a backup whenever you mess up. If you've ever used SVN, it's very similar in the most basic sense.

Github is to Git as Google Code is to SVN - you host projects, wikis, downloads, issue trackers, and of course, source code on it. The biggest difference is that you have to use Git instead of SVN, as implied by the name. So how can you host your code on GitHub? Simple! First you're going to need to create an account. Don't be worried by the pricing nonsense, the free account is free for all public repositories.

Create Your Repository
To create a new repo, click the book with a bookmark in the top right corner, next to your name.


Once you click this icon, you should see this image:



The only thing you really need to fill out on this page is the repository name. You can't have spaces or special characters (though it will automatically replace them with hyphens). You can fill out the description if you want. You can't change it to private if you're on a free account. The last two are only if you know what you're doing. Click "Create repository" when you're done.
You are now at your empty repo. Here's where you have a choice. You can choose the simple "Github for Windows" option, or you can go the cross platform and more difficult method with the command line.

Github for Windows
It would be a good idea at this point to download the program. There's also a mac version, but the steps may be different. I don't know, I'm on windows. But you'll want to download, install, and log in to whatever it tells you to. If it asks you something about an SSH key, you should say yes (I don't know if it asks, I installed it a while ago and I don't remember). After it finishes doing whatever nonsense it needs to load, you should be faced with a screen listing all of your repositories. There should be a "Clone" button next to the one you just created. Click it.


If everything worked right, you should now see something like this:


Now open the directory in explorer, and add a file to it. After a few seconds, the file should show up in Github for Windows. Fill out the yellow box; you need to provide a commit message. Just a simple "added things" works, or you can provide the entire changelog.


Now, you should see the commit in a box on the right. Are you done? Not quite.


So far, you've committed your changes locally. To upload the files and the commit to github, you have to click "publish"


Now check your repo; your file is now uploaded!

Github for command line
If you don't know how to get to the command line, this guide might not be for you. First, make sure you've installed Git; if you're on linux you can use apt-get or yum or whatever package manager you use to download it. If you're on windows, you can use Git for Windows. After you've installed git, you'll need to generate a public key. Go to the command line, and type this in:
Code: [Select]
ssh-keygen -t rsa -C "your.email@email.com"(obviously, you need to put your own email in there). It should ask you where to save it, just press enter. Enter your own passphrase. Once you're done, it should say something like "Your public key has been saved in ...". Go to this directory now. There should be a file named "id_rsa.pub" in the directory. You'll need to add this to github. Go to this page and click "Add SSH key".


The name can be anything you want, but it should be descriptive so you know what computer it belongs to. Put the entire contents of id_rsa.pub into the key box. Then click "Add key". Now go to your repo's page. There should be a link that looks something like this:
Code: [Select]
https://github.com/Username/Project Name.gitCopy this link. Create a new directory or go to an empty one. Type this into the command line:
Code: [Select]
git init
git remote add origin https://github.com/Username/Project Name.git

This creates a new git repository in the directory. It then adds your git repo to the repository, so it knows where to send the code. How does github know that you're sending the code without logging in? With the public key you just created!

Now that you've done this, you can type git add filename to add a file to your repository. Then, just like in Github for Windows, you need to commit & publish it:
Code: [Select]
git commit -m "Message"
git push origin master

If all goes well, congratulations! You have now set up a github repository! Now go publish some code!

Offline AnsisMalins

  • Regular Member
  • **
  • Posts: 55
  • Black belt in .NET
    • LiveStream
Re: How 2 Github
« Reply #1 on: 2012-September 30, 12:17:32 »

Offline CommunistPancake

  • New Foal
  • *
  • Posts: 5
  • That C# guy
    • Blog
Re: How 2 Github
« Reply #2 on: 2012-September 30, 20:53:00 »
The superior GUI for Git.

It's powerful, but it's not simple, and that's what Github for Windows aims to be.

Offline AnsisMalins

  • Regular Member
  • **
  • Posts: 55
  • Black belt in .NET
    • LiveStream
Re: How 2 Github
« Reply #3 on: 2012-September 30, 22:36:53 »
I would say the opposite is true.

Offline DavidVictoria

  • New Foal
  • *
  • Posts: 2
  • Blank flank
    • gclub มือถือ
Re: How 2 Github
« Reply #4 on: 2018-April 17, 11:52:41 »
I also have problems with this part as well.