How to add my current project to an already existing GitHub repository

Solution 1:

Open your Terminal, access to this folder and write:

git init
git add .
git commit -m "my commit"
git remote set-url origin [email protected]:username/repo.git
git push origin master

Solution 2:

I had more luck with navigating in my terminal to the directory I wanted to add to the repository, then (assuming you're working on a branch called master):

    git init
    git add .
    git commit -m "my commit"
    git remote add origin <remote repository URL>
    git push origin master

Here's a link to an article explaining how to do it in more detail: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

Note that you won't be able to run the "git add ." line if the directory in question is open.

Solution 3:

All the answers above seems to guide about creating a new repository in git but the question is about adding a folder to existing repo. To do that following steps can be followed.

  • Clone your existing repo using following command: git clone https://github.com/company/our_repo.git
  • Manually take your project folder to the desired location i.e. trunk/bin
  • Now commit and then push in the repo using the commands: git commit -m "message" and git push origin master

Solution 4:

1. first create a git repostry.
2. second open git bash in  existing or uploading project.
3. perform git init 
4. git add .
5. git commit -m "print message"
6. git remote add github<repostry url>
7. git remote -v
8. git push github master

OR

git push origin master

if you get any error, you may use it

git push -f origin master