How to Fix “shallow update not allowed” When Pushing a Git Clone
When you push a repository you cloned with git clone --depth 1 to another remote, Git rejects it with ! [remote rejected] main -> main (shallow update not allowed). You only have part of the history locally, and the destination does not have the earlier history. Running git fetch --unshallow origin to get the full history, and then pushing again, makes the error go away.
You are most likely to see this message when you move a repository to another server or push to a backup remote, and the original clone was shallow. I reproduced it on purpose in a test environment and confirmed both the message and that it disappears after the fix.
The test environment was Ubuntu 24.04, Git 2.43.0, and bash 5.2. I ran everything with LANG=C so the messages would be in English. The source and destination remotes were all repositories inside the same test environment. I did not test pushing to servers such as GitHub, git push --mirror, running inside GitHub Actions, or Windows and macOS. The output was saved to files, so it does not include the progress lines that a terminal shows while running (for example, Enumerating objects).
- 1. Pushing a shallow clone to an empty remote is rejected
- 2. The cause is that the destination does not accept a shallow state
- 3. Run git fetch –unshallow origin, then push the full history
- 4. If the destination has the history, a shallow push works
- 5. Setting receive.shallowUpdate to true on the destination
- 6. When pushing a repository cloned in GitHub Actions
Pushing a shallow clone to an empty remote is rejected
The source repository neko-repo has five commits on the main branch.
$ git -C neko-repo log --oneline
f1be4c0 メニュー 第5版
d6fcc24 メニュー 第4版
44ced2a メニュー 第3版
893c5fd メニュー 第2版
2c81331 メニュー 第1版
When I cloned it with --depth 1, only the latest commit, "Menu 5th edition", was stored locally. git rev-parse --is-shallow-repository returns true, which confirms that the repository is shallow. I replaced the working directory path in the commands with /path/to.
$ git clone --depth 1 file:///path/to/neko-repo neko-shallow
Cloning into 'neko-shallow'...
$ cd neko-shallow
$ git log --oneline
f1be4c0 メニュー 第5版
$ git rev-parse --is-shallow-repository
true
Next, I added an empty repository created with git init --bare -b main (backup.git) as a remote named backup, and pushed main. The following message appeared, and the exit code was 1.
$ git remote add backup ../backup.git
$ git push backup main
To ../backup.git
! [remote rejected] main -> main (shallow update not allowed)
error: failed to push some refs to '../backup.git'
As described in the output section of the git push official reference, remote rejected means the destination repository refused the update. When I checked backup.git, no commits had arrived.
$ git -C ../backup.git log --oneline
fatal: your current branch 'main' does not have any commits yet
Adding a new commit locally before pushing did not change the result. I made an "Add memo" commit in another shallow clone and pushed it to the empty remote, and it was rejected with the same shallow update not allowed message.
The cause is that the destination does not accept a shallow state
A shallow repository records where its history is cut off in a file called .git/shallow. In this example, that file contained the hash of the "Menu 5th edition" commit.
$ cat .git/shallow
f1be4c02600434ac542aae9b5905ff201edad194
If you push this to an empty remote as it is, the destination would have to become a shallow repository without the parent of "Menu 5th edition". According to the description of receive.shallowUpdate in the git config official reference, when a new ref requires rewriting the destination's .git/shallow, the ref is rejected unless this setting is true. The empty repository I created in the test had no settings changed, so the push was rejected.
![Diagram comparing a push from a shallow clone with a push after running git fetch --unshallow origin. When only the Menu 5th edition commit is available locally, git push backup to an empty remote is rejected with shallow update not allowed. When the full history from Menu 1st edition to Menu 5th edition is available, all five commits are accepted with [new branch].](https://neko-note.org/wp-content/uploads/2026/11/error-git-shallow-update-not-allowed-shallow-update.png)
Run git fetch –unshallow origin, then push the full history
The fix is to convert the shallow clone back into a normal repository that has the full history. Use git fetch --unshallow from the source (origin) to get the remaining history. As described in the –unshallow section of the git fetch official reference, if the source has the full history, the shallow repository becomes a complete one.
$ git fetch --unshallow origin
$ git rev-parse --is-shallow-repository
false
$ git log --oneline
f1be4c0 メニュー 第5版
d6fcc24 メニュー 第4版
44ced2a メニュー 第3版
893c5fd メニュー 第2版
2c81331 メニュー 第1版
--is-shallow-repository now returns false, and all five commits are visible. The .git/shallow file is also gone.
$ ls .git/shallow
ls: cannot access '.git/shallow': No such file or directory
In this state, running the same git push backup main that was rejected earlier succeeded with [new branch]. The exit code was 0.
$ git push backup main
To ../backup.git
* [new branch] main -> main
$ git -C ../backup.git log --oneline
f1be4c0 メニュー 第5版
d6fcc24 メニュー 第4版
44ced2a メニュー 第3版
893c5fd メニュー 第2版
2c81331 メニュー 第1版
$ git -C ../backup.git rev-parse --is-shallow-repository
false
All five commits arrived at the destination backup.git, and it is not a shallow repository.
When I ran git fetch --unshallow origin again in a repository that already had the full history, it failed with the following error. The exit code was 128.
$ git fetch --unshallow origin
fatal: --unshallow on a complete repository does not make sense
If the destination has the history, a shallow push works
A push from a shallow clone is not always rejected. If the destination already has the history before the part that is cut off locally, the destination does not need to become shallow, so the push succeeds.
I added full.git, a clone of neko-repo with the full history, as a remote, and pushed from the shallow repository after making an "Add memo" commit. The local repository stayed shallow, but the push succeeded.
$ git remote add full ../full.git
$ git rev-parse --is-shallow-repository
true
$ git push full main
To ../full.git
f1be4c0..88c3523 main -> main
$ git -C ../full.git log --oneline
88c3523 メモを追加
f1be4c0 メニュー 第5版
d6fcc24 メニュー 第4版
44ced2a メニュー 第3版
893c5fd メニュー 第2版
2c81331 メニュー 第1版
If you only add new commits to a remote that has the same history as the original repository, you can keep the shallow clone. In this test, the error happened only when pushing to an empty remote.
Setting receive.shallowUpdate to true on the destination
If you can configure the destination repository yourself, you can also set receive.shallowUpdate to true. I ran git config receive.shallowUpdate true on an empty repository (backup3.git), and then pushed main from the shallow repository. The push went through without being rejected.
$ git push backup3 main
To ../backup3.git
* [new branch] main -> main
$ git -C ../backup3.git rev-parse --is-shallow-repository
true
$ git -C ../backup3.git log --oneline
88c3523 メモを追加
f1be4c0 メニュー 第5版
The receiving backup3.git became a shallow repository and does not have any history before "Menu 5th edition". A repository cloned from it was also shallow.
$ git clone file:///path/to/backup3.git ../from-backup3
Cloning into '../from-backup3'...
$ git -C ../from-backup3 log --oneline
88c3523 メモを追加
f1be4c0 メニュー 第5版
$ git -C ../from-backup3 rev-parse --is-shallow-repository
true
If your goal is migration or backup, run git fetch --unshallow origin locally and then push, rather than changing the destination's settings.
When pushing a repository cloned in GitHub Actions
actions/checkout in GitHub Actions fetches shallowly by default. According to the actions/checkout README, the default value of fetch-depth is 1, and setting it to 0 fetches the full history of all branches and tags. If you specify fetch-depth: 0, the full history is fetched from the start. In this article's tests, pushing from a repository with the full history succeeded even to an empty remote.
For how to clone with --depth and how to add history gradually with git fetch --deepen, see the separate article, "How to Get a Shallow History with git clone –depth."





