Thursday, September 04, 2014

Create a GitHub Respository and Get Code In it

Quick way to get your code in GitHub

These steps work on Windows.

1. Create an account on http://github.com

2. Recommend multi-factor authentication to require you to enter a pin from your cell phone

     a.  Click on the settings icon :
    b. Click on security on the left

    c. Turn on two factor authentication at the top middle of the screen and follow the instructions to activate.

3. Install the client software. 



4. Create a repository on http://www.github.com
   
    a. Click on repositories in the left menu

    b. Click the plus button (next to the settings button above)
  
    c. Choose New Repository from the download

    d. Type a name for your repository
   
    e. Choose public if you want the world to see your code, otherwise private radio button.

    f. Click create repository.

4. Create the local repository
   
    a. On the repository page, click set up in desktop.

    b.  Click "launch application"

    c.  Create a new folder where you want to have the folder for your repository created.

    d. Click to select the location

    e. A folder will be created with the name of your repo inside the folder you selected and a .git folder
  
    f. Do not alter the git folder - that is used to sync your files with git

    g. Move the files you want to put into github into the repository folder.

5. Ignore things you don't want to go to github

    a. in the root folder of your repository create a file called .gitignore 

    b. in windows right click on the repository folder and choose Git Bash

    c. type on command line: touch .gitignore
    
    d. type the names of files you want to exclude from going to github http://git-scm.com/docs/gitignore

    e. suggest including: encryption keys, logins, AWS keys, other types of credentials, sensitive data

6. Create a Branch (if you want)

   a. Go back to your repository on github

    b. click the down arrow next to master at the top

    c. enter a new branch name

7. Add files to Github in the branch you just created
   
    a. Check the box next to files you want to move to git in your file list

    b. Enter a summary (required) and comment (optional)

    c. Click "Commit to [branch]"

    d. The files are now listed under "Unsynced changes"

    e. Click Publish in top right of the screen to move the files to the server.


Troubleshooting:

- if you have existing attempts to put into github and try to reuse you will probably have conflicts. Make sure to remove the .git directory, if any, from existing code before moving to your new repository directory

- can't create a file staring with . in Windows so use the Git Bash (not command window) as noted above to create the file.

- You cannot create a repository and sync it using the method above if there are existing files where you are trying to create the repository - it's just easier to start with a new directory and move code into it if having issues.

I'm sure there are many other ways to do this - this is what worked quickly for me.