Remote rejected (shallow update not allowed) after changing Git remote URL

前端 未结 6 994
悲&欢浪女
悲&欢浪女 2020-11-28 02:16

I have a project under Git version control that I worked on both a server and my local computer. I originally had the remote origin set as my local computer but I would now

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 02:55

    Another option if you want to keep the repo as is with the new commits you have added since the shallow, initial commit is this: Amend this commit with an interactive 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
      

提交回复
热议问题