6

I have git installed on my Ubuntu server and on my client. I'm planning to install git-flow as well.

When I create a project on the server, to where I will pull either the test branch or the production branch (both are on the same server), after I do the git init, what do I do about naming the remote, given that the repository is on the same server?

JAyenGreen
  • 1,385
  • 2
  • 12
  • 23

1 Answers1

12

If you clone it locally, the remote will be named for you.

git clone /path/to/repo
cd repo
git remote -v

You will see a remote named origin, referring to /path/to/repo.

That would be the same as:

mkdir repo
cd repo
git init .
git remote add origin /path/to/repo
git pull
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So, when I create gits in the test deployment directory and the production deployment directory, which are on the same server as the repo, they point to the same remote with a local path? And I assume I create the repo with the --bare option? – JAyenGreen Oct 24 '13 at 14:01
  • 1
    @Ayen you create a repo with the --bare option only if you want to push to it. See http://gitolite.com/concepts/bare.html. Once create, that repo has no remote. If you clone the bare prod repo as "test" repo, *then* that repo has a remote referring to the prod repo. A repo refers its upstream repo: http://stackoverflow.com/a/2749166/6309. – VonC Oct 24 '13 at 14:07
  • Great, thanks. So to summarize, the repo that will be pushed to by developers and pulled from for deployment (like github) will not need a remote, and those pushing to it or pulling from it will identify it as the remote, with a url if not on the same server, or a local path if on the same server. – JAyenGreen Oct 24 '13 at 14:17
  • 2
    @Ayen sounds about right. When you *create* a repo (`git init`, or "create" on GitHub), it has no remote. But when you *clone* an upstream repo, it has a default remote named 'origin', with the url or local path you used to reference the upstream repo that you just cloned. – VonC Oct 24 '13 at 14:34