sisko
sisko

Reputation: 9900

Using GIT between local sites

I cloned a Git repository to recreate a website in my localhost DEV environment. Later I created a second copy of the site, STAGING, by copying the code base from the first, DEV, site. The staging site has no .git file.

Recently, I've decided to stop coping and pasting from DEV to STAGING. But, how do I initialize Git on STAGING so I can pull changes from DEV?

I tried executing the following:

git init
git remote add origin /var/www/DEV-SITE
git pull

All those commands worked but when I execute git branch or git log, there are no branches nor any log entries.

Update:

Following @cassm, I encounter the following issue which explains why I get no branches:

git pull origin dev
remote: Counting objects: 7957, done.
remote: Compressing objects: 100% (2572/2572), done.
remote: Total 7957 (delta 5300), reused 7841 (delta 5237)
Receiving objects: 100% (7957/7957), 20.40 MiB | 22.63 MiB/s, done.
Resolving deltas: 100% (5300/5300), done.
From /var/www/DEV-SITE
 * branch            dev        -> FETCH_HEAD
 * [new branch]      dev        -> origin/dev
error: Untracked working tree file '.editorconfig' would be overwritten by merge.

Upvotes: 1

Views: 152

Answers (2)

VonC
VonC

Reputation: 1323553

Try and check what you current branch is with git branch -avvv

From /var/www/DEV-SITE
 * branch            dev        -> FETCH_HEAD
 * [new branch]      dev        -> origin/dev

If none is currently set, you can do a:

git checkout dev

That will automatically track origin/dev (imported by the git fetch part of the git pull) and switch to that branch content.

Make sure you don't have any modification specific to STAGING though: they would be overridden.

Upvotes: 1

cassm
cassm

Reputation: 203

The first pull from a remote needs the branch specified. I tend to do this in the format

git pull <remote> <branch>

so in your case this should be

git pull origin master

Upvotes: 1

Related Questions