Add Remote Address : Git allow you to fetch and commit the repository from remote address. Before doing any operation using remote address you need to specify the remote address for the repository. We can connect with remote repository using one of two protocols one is HTTPS and second is SSH.
Once added the remote address you can push the latest commit to remote address and also can fetch the latest records from the remote repository. To set the remote location for the repository you can use the following command :
If HTTPS :
$ git remote add origin https://github.com/user_name/MytestRepo.git
If SSH :
$ git remote add origin git@github.com:user_name/MytestRepo.git
The above command will add a remote repository location to the current local repository. The git remote add takes two parameter as follows :
- A remote name for example 'origin'
- URL of remote location for example 'https://github.com/user_name/Mytest.git'
Verify the remote address is added :
You can check the remote address is added to the repository or not.So git provides a command to check the remote addresses added in a repository:
$ git remote -v
Output:
# Verify new remote
# origin https://github.com/user_name/MytestRepo.git (fetch)
# origin https://github.com/user_name/MytestRepo.git (push)
Pushing file from local repository to Remote Repository :
$ git push origin master
0 Comment(s)