我有一个Git版本控制下的项目,我在服务器和本地计算机上工作。我原来有远程起源设置为我的本地计算机,但我现在想把它改为BitBucket。
在服务器上使用该命令
git remote set-url origin bitbucket_address
但是现在当我试图推动我的项目时,我得到了错误
! [remote rejected] master -> master (shallow update not allowed)
是什么导致了这种情况,我如何解决它?
我有一个Git版本控制下的项目,我在服务器和本地计算机上工作。我原来有远程起源设置为我的本地计算机,但我现在想把它改为BitBucket。
在服务器上使用该命令
git remote set-url origin bitbucket_address
但是现在当我试图推动我的项目时,我得到了错误
! [remote rejected] master -> master (shallow update not allowed)
是什么导致了这种情况,我如何解决它?
当前回答
我解决了这个问题。但也许你无法修复它。解决方法如下。
从git中获取shallow文件,比如common/.git/shallow 把这个文件推到git服务器的。git目录下。 将分支推到git服务器。
在我的公司,我需要IT管理员添加文件,我没有权限。
其他回答
根据投票最多的答案,我创建了一个别名来自动化事情:
添加到你的.gitconfig:
[alias]
unshallow = !"git fetch --unshallow \"${1:-origin}\" # Unshallow from remote $1 (defaults to origin)"
用法:
Git unshallow #基于源远程的非浅当前分支 Git unshallow other-remote #非浅层当前分支从远程other-remote
如果取回。unshallow不起作用。你们的分行一定有问题。在推它之前,用下面的命令修复它。
git filter-branch -- --all
只使用——unshallow不行,因为有安全方面的考虑。
只需删除/.git/shallow中的shallow文件
现在应该可以了。
我解决了这个问题。但也许你无法修复它。解决方法如下。
从git中获取shallow文件,比如common/.git/shallow 把这个文件推到git服务器的。git目录下。 将分支推到git服务器。
在我的公司,我需要IT管理员添加文件,我没有权限。
如果你想保持回购与你添加的新提交一样,那么另一个选择是:用一个交互式的rebase修改这个提交。
Start an interactive rebase including the first (root) commit with git rebase --interactive --root Change the pick of the initial commit(s) to edit and save & close the file. If you've cloned the repo with greater depth than 1, you may need to do the same for all of those commits. Or, alternatively, execute fixup for all of these during the interactive rebase. Convert this commit to a regular, unshallow commit with git commit --amend --no-edit This will also change the commit ID and add you as co-author to this initial commit. Don't forget to finish your rebase git rebase --continue