score:176

Accepted answer

while the egit plugin for eclipse is a good option, an even better one would be to learn to use git bash -- i.e., git from the command line. it isn't terribly difficult to learn the very basics of git, and it is often very beneficial to understand some basic operations before relying on a gui to do it for you. but to answer your question:

first things first, download git from http://git-scm.com/. then go to http://github.com/ and create an account and repository.

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. this assumes you have already created a github repository. you'll get the correct url from your repo in 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

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

score:0

jokab's answer helped me a lot but in my case i could not push to github until i logged in my github account to my git bash so i ran the following commands

git config credential.helper store

then

git push http://github.com/[user name]/[repo name].git

after the second command a gui window appeared, i provided my login credentials and it worked for me.

score:1

for eclipse i think egit is the best option. this guide http://rogerdudler.github.io/git-guide/index.html will help you understand git quick.

score:1

many of these answers mention how to share the project on git, which is easy, you just share the code on git, but one thing to take note of is that there is no apparent "project file" that the end user can double click on. instead you have to use import->general->existing project and select the whole folder

score:2

you need a git client to upload your project to git servers. for eclipse egit is a nice plugin to use git.

to learn the basic of git , see here // i think you should have the basic first

score:47

here is a step by step video of uploading eclipse projects to github

https://www.youtube.com/watch?v=bh4oqyhohc0

adding the steps here.

  1. right click on your eclipse project -> team -> share project

  2. choose git from the list shown; check the box asking create or use repository -> click on create repository and click finish. - this will create a local git repo. (assuming you already have git installed )

  3. right click on project -> team -> commit - select only the files you want to commit and click on commit. - now the files are committed to your local repo.

  4. go to git repositories view in eclipse ( or team -> show in repositories view)

  5. expand the git repo of your project and right click on remotes -> create remote

  6. remote name will appear as origin, select 'configure push' option and click ok

  7. in the next dialog, click on change next to uri textbox and give your git url, username, password and click on 'save and push'. this configures git push.

  8. for configuring fetch, go to git repositories -> remote -> configure fetch -> add -> master branch -> next -> finish -> save and fetch

  9. for configuring master branch, branch -> local -> master branch -> right click and configure branch -> remote: origin and upstream branch : refs/heads/master -> click ok

on refreshing your repo, you will be able to see the files you committed and you can do push and pull from repo.


Related Query

More Query from same tag