I have two directories in /var/www one is a fresh install of Laravel the other is a git clone of a Laravel application.

I basically need the Laravel application to move into the fresh install of Laravel so it can run properly with the requisite /vendor code.

However, I can't figure out how to use the command line to do this. I either rsync and delete the /vendor files because they aren't in the git clone or it doesn't overwrite anything.


I want everything in laravelGithubApplication to come out and overwrite everything in laravelFresh that is a duplicate. I don't want it to sync because whatever is in laravelFresh that doesn't have a duplicate in laravelGithubApplication shouldn't be overwritten.

Please help.

  • Please clarify duplicate. As in identical path/filename or identical in both filename and contents? Also "to come out" is not a common phrase. It could be interpreted as being removed, or moved to the destination directory instead of merely being copied. – Deathgrip Jun 15 '17 at 20:59
  • @Deathgrip duplicate as in both. Come out means moved to destination directory, so laravelGithubApplication should be emtpy at the end. Thank you. – Summer Developer Jun 15 '17 at 21:14
  • I think you need to look at this differently. I believe you'll end up with what you want by copying from laravelFresh into laravelGithubApplication. Identical files don't matter which was used, files that are different you get the laravelFresh file, and any of the Github files that didn't exist in the fresh install remain. – Deathgrip Jun 15 '17 at 21:49
  • @Deathgrip what command would I use for that? – Summer Developer Jun 15 '17 at 23:08

mv laravelGithubApplication/* laravelFresh/

Contents of directories before:


Contents of directories after:

laravelFresh/file (overwritten)

As you wish, duplicate files (file) have been overwritten; existing directories (vendor) remain untouched; and everything has "come out" of laravelGithubApplication/.

  • Doesn't work, directory not empty. – Summer Developer Jun 15 '17 at 23:07
  • Oh, you also have duplicate directories. In that case, you need cp -R laravelGithubApplication/* laravelFresh/ but you lose the emptying of the src directory. – Heath Raftery Jun 15 '17 at 23:37
  • No that just gives me a wrong directory structure, so if I have a duplicate directory it puts it as a subdirectory. So laravelFresh/app becomes /laravelFresh/app/app. That's not what I want. I want any duplicates to be overwritten. – Summer Developer Jun 15 '17 at 23:41
  • Eh, sorry about that. Works fine for me. Directory structure is intact. I can only suggest editing your original question with a before/after directory listing so someone else can try. – Heath Raftery Jun 16 '17 at 0:08

Continuing from our q&a in the comments try this (assuming everything is under /var/www):

# cd /var/www
# mkdir laravelCombined
# cd laravelGithubApplication
# find . | cpio -dumpv /var/www/laravelCombined
# cd ../laravelFresh
# find . | cpio -dumpv /var/www/laravelCombined

Before removing the contents of /var/www/laravelGithubApplication and /var/www/laravelCombined check that what is in /var/www/laravelCombined is what you need. If it is:

# rm -rf /var/www/laravelGithubApplication
# rm -rf /var/www/laravelFresh
# mv /var/www/laravelCombined /var/www/laravelFresh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.