`git` - could not able to create `achive` existing repo

907 views Asked by At

I am trying to export my existing git repo with following command. But I end up with errors. any one help me to fix this?

my command :

PS F:\Nissan-Gulp> git archive --format zip --output F:\convert master
fatal: could not create archive file 'F:\convert': Is a directory
PS F:\Nissan-Gulp>

my existing git project at Nissan-Gulp and I wish to send to 'F:\convert': folder. but not works.

2

There are 2 answers

0
nokko On

This error message is also displayed when a file called FILENAME already exists, but is owned by a user whose files you cannot overwrite. (At least on 'nix-y systems.)

E.g:

# whoami
root
# touch release1.zip
# su schmuck
$ git archive Release1 --format zip -o release1.zip
fatal: could not create archive file 'release1.zip': Permission denied

I ran into this problem attempting to make an archive as the root user, forgetting that I was root and that the root user didn't have a proper Git config, then attempting to make an archive as a regular Joe:

# git archive Release1 -o release1.zip
fatal: unsafe repository ('/var/www/repo' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /var/www/repo

Note that git archive makes an empty file before this "unsafe repository" check is made.

# find . -maxdepth 1 -type f -iname "*" -printf "%f\t%s\t%u\n"
foo             100 schmuck
bar             50  schmuck
baz             200 schmuck
release1.zip    0   root
.gitignore      100 schmuck

And predictably, schmuck cannot overwrite root's file:

# su schmuck
$ git archive Release1 -o release1.zip
fatal: could not create archive file 'sprint2.zip': Permission denied

Simply delete the file as root, then proceed with the archive.

$ sudo rm release1.zip
$ git archive Release1 -o release1.zip
3
Nick McCurdy On

The F:\convert path should be a file, not a directory. Create that directory and run the command with F:\convert\FILENAME, replacing FILENAME with what you'd like to name the archive.