I have directory A with files matching directory B. Directory A may have other needed files. Directory B is a git repo.
I want to clone directory B to directory A bu
This worked for me:
git init
git remote add origin PATH/TO/REPO
git fetch
git reset origin/master # Required when the versioned files existed in path before "git init" of this repo.
git checkout -t origin/master
NOTE: -t
will set the upstream branch for you, if that is what you want, and it usually is.
A slight modification to one of the answers that worked for me:
git init
git remote add origin PATH/TO/REPO
git pull origin master
to start working on the master branch straight away.
I got the same issues when trying to clone to c/code
But this folder contains a whole bunch of projects.
I created a new folder in c/code/newproject and mapped my clone to this folder.
git for desktop then asked of my user and then cloned fine.
Here's what I ended up doing when I had the same problem (at least I think it's the same problem). I went into directory A and ran git init
.
Since I didn't want the files in directory A to be followed by git, I edited .gitignore and added the existing files to it. After this I ran git remote add origin '<url>' && git pull origin master
et voíla, B is "cloned" into A without a single hiccup.
I have used this a few moments ago, requires the least potentially destructive commands:
cd existing-dir
git clone --bare repo-to-clone .git
git config --unset core.bare
git remote rm origin
git remote add origin repo-to-clone
git reset
And voilá!
this is work for me ,but you should merge remote repository files to the local files:
git init
git remote add origin url-to-git
git branch --set-upstream-to=origin/master master
git fetch
git status