push to an existing repo code example

Example 1: git push current project to master

git init
git add .
git commit -m 'First commit'
git remote add origin <remote repository URL>
git push origin master

Example 2: git push existing repo

cd existing_folder
git init
git remote add origin https://gitlab.com/abc.git
git add .
git commit -m "Initial commit"
git push -u origin master

Example 3: initialize a repo and push to github

git init
git add -A
git commit -m 'Added my project'
git remote add origin [email protected]:sammy/my-new-project.git
git push -u -f origin master

Example 4: push an existing repository from the command line

git remote add origin https://github.com/TaherSaid/my-pfe-informatique-mobile.git
git branch -M main
git push -u origin main

Example 5: …or push an existing repository from the command line

git remote add origin https://github.com/davidotu/myfinal_project.git
git branch -M main
git push -u origin main

Example 6: gitlab push existing project commandlie

git config --global user.name "Roka Paudel,Sarmila S."

Tags:

Misc Example