Saturday, November 19, 2016

convert a project directory into new github repo

go to project directory and do following -

git init
git add .

create a repo in github

generate and add public ssh key to git user account under Settings -> SSH and GPG keys

if you get the error "Key already used", you might have used the key in some other github repo
Either you can remove it or create a new pair using following command (NOTE: Press ENTER if it asks for any input to choose default options)
ssh-keygen -t rsa -f ~/.ssh/id_rsa.home

copy contents of id_rsa.home.pub to github

Add the private key to ssh-agent
ssh-add ~/.ssh/id_rsa
If you have generated a new pair, you may need to add the private key (Source: Generate and Add new key)
git remote add origin git@github.com:gituser/myrepo.git
to see impact of above command
git remote -v

You must be ready by now to push to remote repo
git push origin master

No comments:

Post a Comment