Initialize or Clone a Repository
Start fresh with `git init` or copy an existing project with `git clone`, then confirm remotes before making changes.
Create a brand-new repository in this folder
git initInitializes the .git directory so Git can track history. Use it only once per project directory.
Clone an existing repository
git clone https://example.com/org/project.gitCopies the full history and sets up the default `origin` remote. Replace the URL with your repository.
Verify remote configuration
git remote -vShows the fetch/push URLs tied to each remote so you can confirm you are pushing to the right place.
Use this when
- You are starting a new project locally and want Git to begin tracking files.
- You need a local working copy of an existing shared repository.
Pro tips
- Avoid running `git init` inside a directory that is already within another repository; nested repos are rarely intentional.
- After cloning, run `git status` to ensure you are on the expected default branch.
Common pitfalls
- Cloning large repos can take time—consider a shallow clone (`git clone --depth 1`) for CI or experimentation.