What Is GIT Remote?
Table Of Contents:
- What Is GIT Remote?
- How To Check Your Remote Repository Details ?
(1) What Is GIT Remote ?
- ‘Remote’ is the keyword used for to check the remote repository configuration.
- A remote repository is stored on code hosting services like an internal server, GitHub, Subversion, Bitbucket and more.
(2) How To Check Your Remote Repository Details ?
Syntax:
git remote Output:
origin - The default name for the remote repository is the ‘origin’.
Syntax:
git remote -v Output:
origin https://github.com/Subrat/Project.git(fetch)
origin https://github.com/Subrat/Project.git(push) - The above output is providing available remote connections.
- If a repository contains more than one remote connection, this command will list them all.
(3) How To Give A Short Name To Your Remote Repository?
Syntax:
git remote add <short name> <remote URL> Example-1:
git remote add HALO https://github.com/Subrat/Project.git git remote -v Output:
HALO https://github.com/Subrat/Project.git(fetch)
HALO https://github.com/Subrat/Project.git(push) - Here you can see that the remote repository name has been changed.
(4) Remote Repository Operations
View Connected Remotes:
- Shows the remote repositories linked to your local repo.
git remote -v
- Example Output:
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
Add Remote Repository:
- This links your local Git repo to a remote repository named
origin.
git remote add origin https://github.com/user/repo.git
Remove a Remote Repository:
- If you made a mistake or changed repositories, this removes the remote connection.
git remote remove origin
Fetch Changes from a Remote Repository
- Downloads new changes from the remote repository without merging them into your local branch.
git fetch origin
Pull Changes from Remote Repository
- Downloads and merges the latest changes from
mainbranch into your local branch.
git pull origin main
Push Your Code to a Remote Repository
- Uploads your commits to the
mainbranch on the remote repository.
git push origin main
(5) Use Of Remote Keyword
- The “remote” keyword is mainly used for adding and removing the remote repository.
git remote add origin https://github.com/user/repo.git
git remote remove origin
- After you maid the connection you dont need to use “remote” keyword again.
- Like this in below example.
git fetch origin
git pull origin main
git push origin main

