Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

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 but git-clone won't allow me to since the directory is non-empty.

I was hoping it would just clone .git and since all the files match I could go from there?

I can't clone into an empty directory because I have files in directory A that are not in directory B and I want to keep them.

Copying .git is not an option since I want refs to push/pull with and I don't want to set them up manually.

Is there any way to do this?

Update: I think this works, can anyone see any problems? -->

cd a

git clone --no-hardlinks --no-checkout ../b a.tmp 

mv a.tmp/.git .

rm -rf a.tmp

git unstage # apparently git thinks all the files are deleted if you don't do this

1 Answer

0 votes
by (27.5k points)

"origin" is noting just what you nicknamed your remote repository when you ran a command like this:

$ git remote add origin [email protected]:USERNAME/REPOSITORY-NAME.git

Now your Git knows that "origin" points to that specific repository. You could have named it "github" or "repo" or whatever you wanted.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...