Quick list of essential commands to initialize a local repository and push it to GitHub for the first time.
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin {repository-url}
git push -u origin maingit init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin {repository-url}
git push -u origin mainWhat each command does
git init: Initializes the local git repository.git add .: Theaddcommand stages changes for commit, and the dot.selects all files.git commit -m "Initial commit": Creates the first commit. The-mflag allows you to add the commit message directly.git branch -M main: Renames the current branch tomain.Note: This is useful if your default configuration creates the branch as
master.git remote add origin ...: Links the local repository with the remote.originis the alias we’ll use to refer to the repository URL (https://github.com/hunkstalker/stardraw).git push -u origin main: Pushes changes to GitHub. The-uflag links your localmainbranch with the remoteorigin/main, allowing you to simply usegit pushin the future.