How to setup version control on Github?

I’m new to programming and while I’ve played around with the Github for Windows client and Netbeans and such, I haven’t managed to figure out how to push my current code to Github, and don’t really know where to go from there once I do. Any tips?

For a good tutorial on most of the features of git specific to github, try try.github.com. It only covers the command line side, but it’s helpful in better understanding git. When committing with Github for Windows, it’s as simple as commit and sync. As for netbeans, it’s as simple as putting in your git url and github login information into the team menu settings.

When 2337 looked into GitHub, I was recommended Pro Git by Scott Chacon (which is free), and was tremendously useful. I found the GitHub help to be useful when dealing with GitHub, but not with Git itself, the version control system.

As well, the GitHub for Windows client is very poor and not well-written. Frankly, my first ever experience with bash scripts (command-line) was with Git, and it was eye-opening. I highly recommend using Git bash.

I have the repo set up between GitHub and Netbeans but it’s currently empty - how do I move my existing code to it?

WHOOO! Finally figured it out after some google-fu :cool:

For others’ reference, here are the steps I took:

Create your new repo on Github, take note of the https:// address in the edit bar (not url bar)
Install Git Bash from the Git website http://git-scm.com/downloads/
Open Git Bash
Type the following:

(Replacing “Username” with your Username, and “directory” with your directory.)

cd /c/Users/Username/directory-of-project/

Should now show a yellow highlighted directory preceded by a tilde (~)

pwd

Verifies that the current directory is the one typed above

git init

git add .

If it pops up an error message "LF will be replaced by… ", type the following: (If not, continue)

git config user.email "Your email address"

git config user.name "Your name"

git add .

Continuing…

git commit -m 'initial commit message'

git remote add origin https://github.com/YourAccountName/Project.git

That last address is the one I mentioned to take note of earlier

git push origin master

At this point it will give you a login prompt for github. When you type the username and password the characters will be invisible, but they’re there. It confused me at first.

It may give you an error. If not, great, if so, type

git pull origin master

and then when that succeeds,

git push origin master

And now you should be done. Refresh your github repository page and the code should be there.

This looks like a great step-by-step method for teams that want to set up GitHub! I just noticed two small things:

  • The “LF will be replaced by…” message is not an error. Because Windows and *nix (UNIX-like systems such as mac and linux) store line endings differently (Windows uses a sequence two characters, CR and LF, or “carriage return” and “line feed”, while *nix systems only use LF), git has a feature that automatically converts between the two, so that the repository’s contents are always consistent, even if people have committed from different OS’s.
    The answer to this StackOverflow question can make things a bit clearer.
  • Not really a problem, but characters not appearing as you type a password is pretty standard behavior in bash. Although it can be unnerving, it’s actually slightly more secure, because people looking over your shoulder can’t even tell how long the password is, much less what the characters are.

GitHub has some great articles on setting up your environment for using Git and GitHub (setting your GitHub username globally, etc) https://help.github.com/articles/set-up-git

They also go through the process listed above with Creating A Repository

Anything past that, I agree with Colin, go with Pro Git, or check out the Git documentation http://git-scm.com/documentation