Creating a repository from scratch locally and binding it to a remote GitHub URL.
Creating a New Local Repository
If you have an existing project folder locally that isn't under version control, you can initialize a Git database inside it using:
# Initialize local repository
git initThis creates a hidden folder named .git in the root directory.
Binding a Remote Source (GitHub)
To sync this local repository with a remote repository you created on GitHub, add a remote binding address named origin:
# Bind local repository to remote GitHub URL
git remote add origin https://github.com/username/my-repo.git
# Verify connected remote URLs
git remote -vRenaming the Default Branch
By default, git init historically names the default branch master. To rename it to the modern standard main, use:
git branch -M main