Pushing local repository to Github

Install Git

Download and run the latest version of GIT from http://msysgit.github.io/ or http://git-scm.com/

Then go to http://github.com/ and create an account and repository.

During the installation you can accept all of the defaults, do not change ‘Use Git and optional Unix tools from the Windows Command Prompt‘ option for Git and SSH operations, shown below:

 

After the installation is completed, to verify that Git is correctly configured run:

git --version

If the version of Git is displayed, means Git was installed successfully and has been add to path env variable.

On your machine, first you will need to navigate to the project folder using git bash. When you get there you do:

git init

which initiates a new git repository in that directory.

When you’ve done that, you need to register that new repo with a remote (where you’ll upload — push — your files to), which in this case will be github. You’ll get the correct URL from your repo on GitHub.

$ git remote add origin https://github.com/[username]/[reponame].git

You need to add you existing files to your local commit:

git add .   # this adds all the files
git pull https://github.com/[username]/[reponame].git

Then you need to make an initial commit, so you do:

git commit -a -m "Initial commit" # this stages your files locally for commit. 
                                  # they haven't actually been pushed yet

Now you’ve created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:

git push -u origin --all
Advertisements