less than 1 minute read

GIT Cheatsheet

Create a new repository on the command line

echo "# aviz" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/brenobeirigo/aviz.git
git push -u origin main

Push an existing repository from the command line

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

Start with branch “main”

git init -b main

Rename default branch master -> main

git branch -m master main
git push -u origin main

Updating .gitignore

Tutorial: https://www.codeblocq.com/2016/01/Untrack-files-already-added-to-git-repository-based-on-gitignore/

git rm -r --cached .

Next:

git add .

Then:

git commit -m "Updated gitignore"

Updated: