Skip to content
  • Initializing & Remotes · Git & GitHub

Initializing & Remotes

LearnViaNotes @learnvianotes· 1 min read

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:

Shell
# Initialize local repository
git init

This 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:

Shell
# Bind local repository to remote GitHub URL
git remote add origin https://github.com/username/my-repo.git

# Verify connected remote URLs
git remote -v

Renaming the Default Branch

By default, git init historically names the default branch master. To rename it to the modern standard main, use:

Shell
git branch -M main

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report