25

I am editing a git repository that was cloned using --depth 1 (shallow clone).

I want to push my changes (commits) but I get this error:

$ git push
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 56.88 KiB | 0 bytes/s, done.
Total 8 (delta 5), reused 0 (delta 0)
fatal: protocol error: expected old/new/ref, got 'shallow deeb2171db739fd366...'
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

How can I solve this?

Running git --version I get this:

$ git --version
git version 1.9.rc1
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
  • 1
    Pushes from shallow clones was added in Git 1.9, which you obviously run on the client, but what about the server? It looks like the pushing-shallow-clone feature required changes to the Git protocol and that your server doesn't recognize what the client is sending. – Magnus Bäck Feb 04 '14 at 16:01
  • 1
    @MagnusBäck Can I do something to solve this if my repo is hosted on Bitbucket? – Ionică Bizău Feb 04 '14 at 16:02
  • Assuming I was right about the problem being that the server is too old, no. You'd have to wait for them to upgrade to support the new protocol. – Magnus Bäck Feb 04 '14 at 16:04
  • Well, unless you don't want to copy your work into a non-shallow repository as described in one of the answers. – Magnus Bäck Feb 04 '14 at 16:34
  • @MagnusBäck Yep, the second solution is shorter and easier in my case. – Ionică Bizău Feb 04 '14 at 17:40

1 Answers1

43
git fetch --unshallow

Also see: how to unshallow your repo

Community
  • 1
  • 1
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168