toolz
toolz

Reputation: 73

git clone without replacing file tree

I have a gitignore that only sends two subdirectories to github.

my gitignore

/*
!/conf
/conf/*
!/conf/jingle_profiles
!/conf/dialplan

this uploads the two subdirectories (dialplan,jingle_profiles) to github.

I want to clone those subdirectories into the root file tree (/usr/local/freeswitch) and have them keep those two subdirectories synced without deleting everything else.

edit:

the error I get when I:

sudo git clone https://github.com/dgmcguire/freeswitch.git

is

fatal: destination path 'freeswitch' already exists and is not an empty directory.

Upvotes: 1

Views: 1315

Answers (2)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174309

git clone requires an empty directory, but subsequent pulls won't do anything to ignored files.

So, simply create an empty subdirectory inside /usr/local/freeswitch, do your git clone inside that subdirectory and afterwards, move the contents of this subdirectory to /usr/local/freeswitch.

Should be something like this:

mkdir /usr/local/freeswitch/git_tmp
cd /usr/local/freeswitch/git_tmp
git clone https://github.com/dgmcguire/freeswitch.git
mv /usr/local/freeswitch/git_tmp/* /usr/local/freeswitch/
rm -r -d /usr/local/freeswitch/git_tmp

I am no linux guy, so there might be some errors in the commands used - the intent however should be clear.

Upvotes: 2

sinelaw
sinelaw

Reputation: 16553

.gitignore is not specifically related github or uploading stuff. It controls which files git considers when checking for untracked files.

I recommend you learn a bit more about how git works. A very, very good resource is ProGit - here's where it discusses .gitignore, but you should really read the first few chapters.

Upvotes: -1

Related Questions