Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

How can I import source code from my computer to my GitHub account?

1 Answer

0 votes
by (50.2k points)

If you want to add local code to a new remote git repository without 'cloning' the old remote, do the following

Create the remote repository and get its url like:

[email protected]:/youruser/somename.git or https://github.com/youruser/somename.git

Locally, at the root directory of your source,

git init

(If you initialize the repo with a .gitignore and a README.md you should do a git pull {url} to ensure you don't commit files to source that you want to ignore). 

Add and commit what you want in your initial repo.

To attach your remote repo with the name 'origin' 

git remote add origin [URL ]

Execute git pull origin master to pull the remote branch so that they are in sync.

To push up your master branch:

git push origin master

Thus, you can import existing code to github.

Browse Categories

...