H. NetIrrigate
H. NetIrrigate

Reputation: 45

How do I synchronize an existing local directory and an existing remote git repo?

I have a local directory and a remote git repository. Both contain the same files. However, the local directory is not yet connected to the remote repo. How can I connect them? The commands I have tried so far did not work because the local directory is not empty.

Not sure if this makes a difference but the local folder and the remote repo do not have the same names.

Upvotes: 2

Views: 4408

Answers (2)

picas
picas

Reputation: 358

If I understand you well, you want to link two local directories, of which one is already a git clone:

cd your/NOT/git/clone/dir
git init .
git remote add origin http...
git fetch -p --all

And to really "link" you two directories, you could even add a local remote:

git remote add file:///path/to/original/local/clone

Upvotes: 1

Leroy
Leroy

Reputation: 247

git remote set-url origin //path/to/repo.git

and either

git pull origin [your branch] or git push origin [your branch]

Upvotes: 4

Related Questions