Introduction
This guide explains how to add a new remote repository in Git using Lazygit. This is particularly useful when you need to track multiple remote repositories or when you set up a new remote repository.
Lazygit
-
Press
3
to navigate to the 3. Local Branches panel. -
Press
]
to switch to the next tab, which is “Remotes”. -
Press
n
to initiate the creation of a new remote. -
Enter the desired remote name when prompted.
-
Enter the remote’s URL. Make sure to use the correct URL format (e.g.,
https://github.com/user/repo.git
for GitHub repositories).Note: Ensure that the URL is correct as this is where your local repository will push to and pull from.
-
After entering the URL, confirm to complete the addition of the new remote.
- Add#screenshot showing the remote addition confirmation.
-
You can now use this new remote for various Git operations like push, fetch, and pull.
Basic Terminal
-
Open your terminal.
-
Navigate to your local Git repository using the
cd
command. -
Use the
git remote add
command to add a new remote. Replace<remote-name>
with your desired remote name and<remote-url>
with the remote’s URL.For example:
-
To verify that the new remote has been added, list all the existing remotes:
This command will display all the remotes along with their associated URLs.
-
You can now use the new remote for pushing and pulling changes.
Remember, adding a remote in Git is a foundational task that enables collaboration and version control across different repositories. It’s essential for working with team members or contributing to open-source projects.