github
adding ssh public key
You can use github without ssh key. But when you add ssh key and you use ssh private key without passphrase, it is convinient for scripting.
Login and follow menu like below: Settings > SSH and GPG keys > New SSH key Then register name and content of your ssh public key.
edit ssh config file
cat << END | tee -a .ssh/config
Host github.com
IdentityFile ~/.ssh/id_rsa.mykey
User git
Host *.github.com
IdentityFile ~/.ssh/id_rsa.mykey
User git
END
test ssh connection. add -v to see debug messages
ssh -T github.com
When you've already work with any github repository, if you want to use git protocol instad of https, you can use it.
git config --local url.git@github.com:.insteadOf https://github.com/
git config --local url.git@gist.github.com:.insteadOf https://gist.github.com/
git config --local --list
git remote -v
After Create a new repository
when you don't have ever created a git repository
git init
git add README.md
git commit -m "first commit"
after that add remote to the repository, and push it.
git remote add origin git@github.com:username/myrepositoryname.git
git remote -v
git push -u origin master
To .gitignore file, add list of files which you don't want to add to the git repository
cat << END | tee -a .gitignore
id_rsa
END
initialize history of repository
rm -rf .git
git init
git add .
git commit -a -m "<commit message>"
git remote add origin <url>
git push -u origin master -f