git add repository to local code example

Example 1: upload new repo to git

echo "# Can-I-Shop-2" >> README.md
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/username/projectname.git
git push -u origin master

Example 2: create github repo with bash

winpty curl -H 'Authorization: token [GENERATED_TOKEN]' https://api.github.com/user/repos -d '{"name":"[REPO_NAME_YOU_WANT]"}'

# follow steps here to generate token:
https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

# note : you can add parameters to you command to set a description, switch to private, etc...

Example 3: create a git repository from local machine and push it online

#initialize 
git init 
# add your URL , it can be local or remote one 
git remote add origin <YOUR_URL>
# commit something
git add *
git commit -m "your message"
# push to your repository 
git push origin master
# you can then go and check online

Example 4: how to add a repository to github

git & github

Tags:

Misc Example