adding a new web project to github

git, github

Solution

You likely selected the "Initialize this repository with a README" option when you created the repository on github. That created a commit in the repository on github which you don't have.

There are two general ways to create a new repository and share it on github:

1) Create a repository on github, selecting the "Initialize this repository with a README" option. Then clone that repository, add your files and push it back up.

2) Create a repository on github, do NOT select the "Initialize this repository with a README" option, which will create an empty repository on github. Initialize your project on your local machine as a git repository, point it to the github project, and push.

What you did was create a repository with content on github and then tried to push a repository with different content.

You can fix this in one of two ways:

1) Delete the github repository and recreate it, without selecting the "Initialize this repository with a README" option. You should then be able to push from your local repo without error.

2) Do a git pull to merge the README into your local repo, and then push. However, this may be a bit confusing because git may complain that you haven't told it what branch to pull to. I'm not familiar enough with the Eclipse UI to tell you how to do that. On the command-line, you'd do `git pull origin master:master`

Fix 1 is likely the simplest if you're new to git.

Problem

I am new to git. I just started using it. Please help. Where am I doing something wrong? I have to add a spring web project to github. I created a new repository on github. In my netbeans I did a right click Versioning->Intialize git Repository. Then I right clicked on the project again and did git->Add and then git->Commit. Then I did a git->Push->chose my github repository url->checked the master checkbox and clicked finish. I am getting a push error "push would result in a non-fastforward update", and my files are not pushed. Do I need to do it at the files level but not at a project folder level? Please help.

Original source