New github repo from local code

Github - social coding

Here is a list of git commands for getting a project that you have already started working on locally up onto Github. Here are instructions on forking a repo – getting the first copy of the project your are interested in onto your computer.

1. Create the repo online

Create the repo on github.com, along with the readme.md.

2.  Initialise git locally

Assuming there are already source code files locally, go to the project folder and set up all of the local git files by running:

git init

3. Pre-commit, add new or updated file to staging area

git add <file>

4. Commit changes

git commit

5. Add a remote git repository

origin is the default name for a “remote” pointing to your remote repo. The repo URL can be found on the right hand side of the Github repo page.

git remote add origin <repo url>

6. Sync the local and remote repos

Sync the remote repo (accessed via origin) to the local master branch – they’ll be a readme.md in there. “pull” is a shortcut for a “fetch” and a “merge”.

git pull origin master

7. Push committed files to remote repo

The github username and password will be needed for this.

git push origin master

Share