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

I have a non-empty directory (eg /etc/something) with files that cannot be renamed, moved, or deleted.

I want to check this directory into git in place.

I want to be able to push the state of this repository to a remote repository (on another machine) using "git push" or something similar.

This is trivial using Subversion (currently we do it using Subversion) using:

svn mkdir <url> -m <msg>

cd <localdir>

svn co <url> .

svn add <files etc>

svn commit -m<msg>

What is the git equivalent?

Can I "git clone" into an empty directory and simply move the .git directory and have everything work?

1 Answer

0 votes
by (50.2k points)

As the question shows that you've set up a git-daemon on <url> and an empty repository:

To resolve this you can use the following commands:

cd <localdir>

git init

git add .

git commit -m 'message'

git remote add origin <url>

git push -u origin master

Which will help you to convert existing non-empty directory into a git working directory.

Browse Categories