In this article you will learn how to add remote repository in git your current local project directory. Suppose you are working on any project since long time but you did not added this project into your Git. So now you have to create a remote git repository and add your project under it.
Add Remote Repository in Git
If you want to add your git remote repository go to your project directory and use git remote add command to connect local directory to remote repository.
$ cd /home/santosh/app1 $ git remote add origin [email protected]:projects/app1.git
Remote URL Checking
Follow the below command to check remote URL in the local copy of code, you can see there are two urls one for Fetching and another for Pushing operation.
$ git remote -v origin [email protected]:project/app1.git (fetch) origin [email protected]:project/app1.git (push)
Question 1 : What is git remote add?
Answer : If you want to connect record to your remote repository git remote add command will help.
Question 2 : What is difference between local and remote git repository?
Answer : In the git local repository you make changes into your local repository and it is called local repository. Git remote repository means it is located on remote site you can say it is remote server where you push all our local changes to remote repository.
Question 3 : How to create a local repository?
Answer : If you want create a local repository you can run git init command. Got to your directory where you want to keep your local repository. Type git init command. Add some file with code then type git add command to add file in local repository. Now run merge your code repository run git commit command.
Question 4 : What is git bare repository?
Answer : Generally, git bare repository is a repository that is created without any working tree.
Question 5 : How to clone git local repository?
Answer : Git clone command is most import command to clone your any repository. It is used to create a copy of any target repo. The target repo can be local or remote.