Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing project from computer to GitHub repository

Tags:

git

github

Tried to find this but did not find any straightforward way to do it. I am trying to import project from my computer to GitHub repository. Repository is already created by sysadmin and its currently empty.

I know there is another way that I can clone the repository to my computer then copy my project folder to that folder and then commit push. but this approach will require me to change project location in eclipse also by again importing project from the new location.

I don't want that. Is there an easy way I can just push the project to the repository from my current location on my computer.

like image 551
Nirmal Mangal Avatar asked Mar 15 '26 03:03

Nirmal Mangal


2 Answers

From the Github documentation:

Push an existing Git repository
>cd [existing_git_repo on your computer]
>git remote add origin [email protected]/[username]/[project_name].git
>git push -u origin master

Note that it does need to be an empty project in Github without having to do any conflict resolutions.

like image 135
cchapman Avatar answered Mar 17 '26 04:03

cchapman


Your Project doesn't use git

  • In Terminal, change the current working directory to your local project.

  • Initialize the local directory as a Git repository.

    $ git init

  • Add the files in your new local repository. This stages them for the first commit.

    $ git add .

    This adds the files in the local repository and stages them for commit Commit the files that you've staged in your local repository.

    $ git commit -m 'First commit'

    Commits the tracked changes and prepares them to be pushed to a remote repository Copy remote repository URL field at the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.

  • In Terminal, add the URL for the remote repository where your local repostory will be pushed.

    $ git remote add origin remote repository URL

    Sets the new remote

    $ git remote -v

    Verifies the new remote URL

  • Push the changes in your local repository to GitHub.

    $ git push origin master

    Pushes the changes in your local repository up to the remote repository you specified as the origin.

Your project already uses git

  • If this is the case you need steps 1, 5 and 6.

You can find more info about adding projects to GitHub on official docs.

like image 31
rastasheep Avatar answered Mar 17 '26 03:03

rastasheep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!