Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm writing a Makefile to sync my local dotfiles with GitHub. I recently decided to also add my .vim folder to the repo. But when trying to copy the .vim folder I keep getting a Permission denied error.

The line in the Makefile that should copy the folder is:

@$(foreach file, $(FILES), echo "Copying $(BASH_DIR)$(file) to ."; cp -R $(BASH_DIR)$(file) . ; )

The permissions for the .vim folder is drwxr-xr-x, and the error message I get is:

cp: ./.vim/bundle/editorconfig-vim/.git/objects/pack/pack-bbb66dd84e2bdd3b05e19454b0800a928ecb94db.idx: Permission denied
cp: ./.vim/bundle/editorconfig-vim/.git/objects/pack/pack-bbb66dd84e2bdd3b05e19454b0800a928ecb94db.pack: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/4d/e66757eebe4798eaaf02e3762a152d283eca81: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/58/165f0e58211f8a5910df65414cc637651f046a: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/6e/e90f3cfbd7c4956892da49896f62614448f851: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/fc/161ff6515d405831c65c608d63627aa60c4066: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/pack/pack-182ea16d08e5b471d5ce5f545f599f24ebe306cf.idx: Permission denied
cp: ./.vim/bundle/snipmate.vim/.git/objects/pack/pack-182ea16d08e5b471d5ce5f545f599f24ebe306cf.pack: Permission denied
cp: ./.vim/bundle/vim-jade/.git/objects/pack/pack-20254027167dcc621463c4454ed0fc539cf0b1da.idx: Permission denied
cp: ./.vim/bundle/vim-jade/.git/objects/pack/pack-20254027167dcc621463c4454ed0fc539cf0b1da.pack: Permission denied
cp: ./.vim/bundle/vim-markdown/.git/objects/pack/pack-b18aa89f38b322d622d05d969a9df41915bf9ea8.idx: Permission denied
cp: ./.vim/bundle/vim-markdown/.git/objects/pack/pack-b18aa89f38b322d622d05d969a9df41915bf9ea8.pack: Permission denied

Does anyone know how I can get this to work? Preferably without having to change permissions manually.

@vonbrand I am trying to add my vim setup to my dotfiles for easy access on other terminals. I am using pathogen to handle my vim plugins. They are handled by cloning the plugins into the .vim/bundles directory. When I try to cp -r .vim into my dotfiles folder I get the error above. I'd like to find some solution for having these repos as a part of my dotfiles folder without having to manually change the permissions, as this would force me to repeat that process each time I decided to add or change a plugin. I don't know if the solution I'm looking for is passing some option to cp, or using some other tool for copying or syncing the .vim directory, or if chown is the only option I have.

ls -ld ~/.vim/bundle/vim-jade/.git returns drwxr-xr-x 12 $USER staff 408 Jan 21 15:26 ~/.vim/bundle/vim-jade/.git

share|improve this question
I am pretty sure this is unrelated to git and you have problems due to some wrong permissions, i.e. wrong user –  Ulrich Dangel Jan 22 '13 at 9:30
Try chmod -R u+rwX ~/.vim such that you can write to all files/directories there. If it fails, you do not own all files and need to run chown -R YOURUSERNAME ~/.vim as root. –  jofel Jan 22 '13 at 9:48
Please be more specific on what you are trying to get done. From the listing, .vim contains a bunch of git repositories on its own. Is the user doing the git stuff in .vim somebody other than you perhaps? What does e.g. ls -ld .vim/bundle/vim-jade/.git return? –  vonbrand Jan 22 '13 at 9:55
Assuming your github directory is under git control, you don't want the .git directory inside .vim. You should exclude it. You could us the BASH builtin cp -r !(exclude_me) to do that. –  Herman Torjussen Jan 22 '13 at 10:46
It's really weird to be copying a .git directory. Are you sure you aren't looking for git push? –  Gilles Jan 22 '13 at 22:52
show 1 more comment

1 Answer

I've been doing something very similar for some years now, and ended up using symlinks to avoid having to copy stuff back and forth. If you in addition want to have other repositories within the .vim directory you can easily do that with Git submodules (used for example for common makefile includes and shell scripts in mkgithub).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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