github connect to repository code example
Example 1: set up git repository
# New local repository
git init
git add .
git commit -m "Initial commit"
# New remote repository
# Create remote repository (likely on github), then:
git remote add origin https://github.com/username/new_repo #https
git remote add origin git@github.com:username/new_repo #ssh
# Now push
git push -u origin master
Example 2: connect to github repository from terminal
to connect your repository from your terminal to your github requires you
1) Create a github repository than
2) Open Terminal
3) You will initilize git and make a branch with: git init -b main
3) Followed by the command: git add . - this adds all your edited work.
4) Followed by a Commit Command: git commit -m "this is my work" - used for
merging
5) At the top of your GitHub repository's Quick Setup page, click to
copy the remote repository URL.
6) In terminal add the repository URL where your local repository will be
pushed to: git remote add origin <REMOTE_URL> - sets the new remote
7) git remote -v -Verifies the new remote URL
8) Push Changes in local Repository to GitHub: git push -u origin main -
Pushes the changes in your local repository up to the remote repository
you specified as the origin
Example 3: add github repo
create a new repository on the command line
echo "# {Repo Name}" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/cdcdianne/ReactJS-TheMovieDB.git
git push -u origin main
push an existing repository from the command line
git remote add origin https://github.com/cdcdianne/ReactJS-TheMovieDB.git
git branch -M main
git push -u origin main
Example 4: create a repository git terminal
git init
git add somefile
git commit -m "initial commit"
git remote add origin https://github.com/username/new_repo
git push -u origin master
# New local repository
git init
git add .
git commit -m "Initial commit"
# New remote repository
# Create remote repository (likely on github), then:
git remote add origin https://github.com/username/new_repo #https
git remote add origin git@github.com:username/new_repo #ssh
# Now push
git push -u origin master
Example 5: how to push existing project to github
git remote add origin
https://github.com/asd/FinraDeck.git (github adresi)
• git push -u origin master
Example 6: github create repository command line
git **create -d "\<commit name\>"**