Setting a remote repository connects your local Git project to platforms like GitHub, allowing you to push and pull code changes easily.
A remote is a version of your repository hosted on a server such as GitHub. It allows collaboration and synchronization between developers.
// Add a new remote repository
git remote add <remote-name> <remote-url>
// Add GitHub repository as origin
git remote add origin https://github.com/username/repository.git
// List all configured remotes
git remote -v
// Update existing remote URL
git remote set-url origin https://github.com/newusername/newrepository.git
// Remove an existing remote
git remote remove origin
// Push local branch to remote
git push origin main
// Pull updates from remote
git pull origin main
Visualize Git as a bridge connecting your local system and GitHub where push sends changes up and pull brings changes down.