~/
hackweb.dev
Working with Remotes
Quiz
⌘K
...
~/
/tutorials
/git/git-remote/edit
~ Contribute
Suggest a correction or improvement. The author reviews it before it goes live.
Loading...
Comment
0 / 300
Typo
Grammar
Broken link
Clarify
Code
en/tutorials/git/10git-remote
Write
Preview
Diff
# Working with Remotes A remote is a version of your repository hosted elsewhere (GitHub, GitLab, etc.). `origin` is the default name. ## Viewing Remotes ```bash git remote -v ``` Shows the URLs of all configured remotes. ## Adding a Remote ```bash git remote add origin https://github.com/user/repo.git ``` ## Removing a Remote ```bash git remote remove origin ``` ## Renaming a Remote ```bash git remote rename origin upstream ``` ## HTTPS vs SSH - **HTTPS**: `https://github.com/user/repo.git` — requires token/password - **SSH**: `git@github.com:user/repo.git` — uses SSH keys, no password prompts Set up SSH keys for easier authentication: ```bash ssh-keygen -t ed25519 -C "your@email.com" ``` ## Best Practices - Use SSH for personal machines - Use HTTPS for CI/CD pipelines - Keep remote names consistent (`origin`, `upstream`) - Never commit credentials to the repository ## Common Mistakes - Confusing `origin` with `main` - Pushing to the wrong remote - Forgetting to add a remote after cloning - Using unencrypted URLs with sensitive data
No changes yet
Reset to original
Submit suggestion
cancel