What's the correct workflow? git init locally & git-repo #178737
-
|
Hi everyone
Both seem to work in various tutorials, but I'm not sure which approach is cleaner or actually used in real projects. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Great question, this confused me too! If you've already started locally, no problem: just add the remote later with: |
Beta Was this translation helpful? Give feedback.
-
|
Both approaches work, but here’s the general rule used in most real projects. If you’re starting from scratch: Create the repo on GitHub first, then git clone it locally. If you already have local code: You can still start with git init and add the remote later: git init This is totally valid, you’re just connecting your local history to GitHub afterward. In practice: No wrong choic, just pick the one that fits your flow 😊 |
Beta Was this translation helpful? Give feedback.
Great question, this confused me too!
Both methods work, but it's usually easier to create the repository on GitHub first and then clone it locally.
This way, everything is already connected and you don't need to use
git remote addor rename branches later.If you've already started locally, no problem: just add the remote later with:
git remote add origin
git branch -M main
git push -u origin main