Origin file:///c/git-local-repository-example/my-project.git/ (push) Origin file:///c/git-local-repository-example/my-project.git/ (fetch) In above example after cloning: MINGW64 /c/git-local-repository-example/other-client/my-project (master) We can see that info by using git remote -v (-v flag is for verbose). The time when we invoke the 'clone' command with the specified remote url, git automatically saves that as a tracked repository by the name of 'origin'. Receiving objects: 100% (3/3), MINGW64 /c/git-local-repository-example/other-client/my-project (master) Remote: Total 3 (delta 0), reused 0 (delta 0) Remote: Counting objects: 100% (3/3), done. $ git clone file:///c/git-local-repository-example/my-project.git/. $ cd MINGW64 /c/git-local-repository-example/other-client/my-project Let's create a new directory representing another client (other than the original one my-project) and clone the remote project MINGW64 /c/git-local-repository-example * master Cloning remote project from a new clientĬloning a remote repository copies the target repository to local file system. Let's see the logs again inside our repository: MINGW64 /c/git-local-repository-example/my-project.git (BARE:master)Ĭommit 6decbea4a2b4e9fe4f54814e9821d95ba74171b7 ( HEAD -> master )Īdding MINGW64 /c/git-local-repository-example/my-project.git (BARE:master) Note that we used file:// at the beginning of our repository url, indicating the repository is located on the local file system. To file:///c/git-local-repository-example/my-project.git/ $ git push file:///c/git-local-repository-example/my-project.git/ master $ cd MINGW64 /c/git-local-repository-example/my-project (master) My-project/ MINGW64 /c/git-local-repository-example Let's use push command in our example: MINGW64 /c/git-local-repository-example So far there's no relation between our project (my-project) and the repository (my-project.git), but now we are going to push our project to the repository for the first time. We can also use git branch command (but right now we have no project branches) MINGW64 /c/git-local-repository-example/my-project.git (BARE:master) In above example, since my-project.git does not yet have any projects, it will return an error: MINGW64 /c/git-local-repository-example/my-project.git (BARE:master)įatal: your current branch 'master' does not have any commits yet We can use git log for the bare repository to see the commit history. git directory and without a working tree.īy convention, bare repository main directory name ends with the suffix. It has all commit history but without a parent. It has similar directory structure what we see inside the. What is a bare repository? A bare repository doesn't contain a working directory. In above example we used git init -bare to create a bare repository. Initialized empty Git repository in MINGW64 /c/git-local-repository-example/my-project.git (BARE:master) $ cd MINGW64 /c/git-local-repository-example/my-project.git Let's create a directory (my-project.git) representing the remote repository for our above project: MINGW64 /c/git-local-repository-example Now let's host above project from a central location on the file-system which will be acting as remote repository. So far there's nothing new, we have been doing same thing in previous tutorials. The file will have its original line endings in your working MINGW64 /c/git-local-repository-example/my-project (master) Warning: LF will be replaced by CRLF in readMe.txt. $ echo test content > MINGW64 /c/git-local-repository-example/my-project (master) Initialized empty Git repository in MINGW64 /c/git-local-repository-example/my-project (master)
$ cd MINGW64 /c/git-local-repository-example/my-project
$ mkdir MINGW64 /c/git-local-repository-example $ MINGW64 /c/git-local-repository-example Let's start git bash from which we will create a project under a directory 'my-project' and will add that to Git. Let's see that step by step with an example.
#Git add remote url to local repository how to
In this tutorial we will keep the things simple and see how to push, clone and pull projects over the local protocol (local file system). The main purpose of a remote repository is to place the repository to a central location so that it can be accessed by multiple developers.Ī remote repository can be accessed via http, ssh or even local (file-system) protocols. The remote Git repositories host our projects through the Internet or network.