git init -y 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 [email protected]:username/new_repo #ssh
# Now push
git push -u origin master

Example 2: git init repo

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

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: 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 5: git init

cd /path/to/my/codebase
git init   
git add .    
git commit -m "my comment"

Example 6: git init

cd /path/to/my/codebase
git init   
git add .    
git commit -m "my comment"