[英]How to push an existing local repo into a newly remote one without loosing git history
我有一些歷史的本地git回購。
我想將其添加到我的遠程git服務器中:
# On my server, I create a remote repo
git init project.git --bare --shared
# On my local computer, I add the remote repo
git remote add origin user@server:/srv/git/projet.git
# Try to push
git push origin master
# error: src refspec master does not match any.
# error: failed to push some refs to 'user@server:/srv/git/projet.git'
# Try to pull
git pull origin master
# fatal: Couldn't find remote ref master
# fatal: the remote end hung up unexpectedly
如果我先克隆遠程倉庫,然后復制源代碼,我將丟失git歷史記錄。
有人知道該怎么做嗎?
我想您已經在本地正確管理了您的倉庫(git add,commit等),所以這可能不起作用,因為在源(您的服務器)上還沒有分支母版,因為它是裸機並且您尚未克隆最初來自服務器的倉庫。
你應該試試
git push -u origin master
它也應該推送並創建遠程主分支
從文檔https://git-scm.com/docs/git-push#git-push--u
對於每個最新的或成功推送的分支,添加上游(跟蹤)引用,該引用由無參數git-pull [1]和其他命令使用。 有關更多信息,請參見git-config [1]中的branch..merge。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.