我在GitHub的某個位置有我的項目,[email protected]:myname/oldrep.git
。'git push'已經存在於一個新的版本庫中的遠程原點
現在我想將我的所有代碼推送到其他位置的新存儲庫[email protected]:newname/newrep.git
。
我使用的命令:
git的遠程添加原點[email protected]:MYNAME/oldrep.git
但我接收到該:
致命:遠程原點已經存在。
我在GitHub的某個位置有我的項目,[email protected]:myname/oldrep.git
。'git push'已經存在於一個新的版本庫中的遠程原點
現在我想將我的所有代碼推送到其他位置的新存儲庫[email protected]:newname/newrep.git
。
我使用的命令:
git的遠程添加原點[email protected]:MYNAME/oldrep.git
但我接收到該:
致命:遠程原點已經存在。
您正在收到此錯誤,因爲「原點」不可用。 「起源」是一個不屬於命令的約定。 「origin」是遠程存儲庫的本地名稱。
例如,你也可以這樣寫:
git remote add myorigin [email protected]:myname/oldrep.git
git remote add testtest [email protected]:myname/oldrep.git
參見手冊:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
要刪除您輸入遠程倉庫:
git remote rm origin
再次 「原點」是遠程存儲庫的名稱,如果你想要 刪除「上游」遠程:
git remote rm upstream
你也可以改變你要推到在REPOHOME/git的/ config文件
(其中REPOHOME是你的本地克隆路徑倉庫名的存儲庫)。
您可以在文本編輯器中簡單編輯配置文件。
在~/.gitconfig
你需要把東西像如下:
[user]
name = Uzumaki Naruto
email = [email protected]
[github]
user = myname
token = ff44ff8da195fee471eed6543b53f1ff
在oldrep/.git/config
文件(版本庫的配置文件中):
[remote "github"]
url = [email protected]:myname/oldrep.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
如果有存儲庫配置文件中的遠程部分以及URL匹配,您只需添加推送配置即可。如果您使用公共URL進行抓取,您可以將URL作爲'pushurl'(警告:這需要剛剛發佈的Git 1.6.4版)。
如果錯誤命名的本地名稱爲「原產地」,你可以用下面的刪除:
git remote rm origin
您不必刪除現有的「原產地」遙控器,只需使用一個名稱除了遠程添加的「來源」以外,例如
git的遠程添加github上 [email protected]:MYNAME/oldrep.git
以前的解決方案似乎忽略原點,他們只建議使用其他名稱。當您只想使用git push origin
時,請繼續閱讀。
問題出現是因爲Git配置的順序錯誤。您可能已經在您的.git配置中添加了「git origin」。
你可以用下面的行改變你的Git配置中的遠程產地:
git remote set-url origin [email protected]:username/projectname.git
這條命令設置一個新的URL爲要推到Git倉庫。 重要的是要填你自己的用戶名和項目名稱
我得到了同樣的問題,這裏是做一些研究後,我如何固定它:
Git Shell
。這將打開包含Git命令的電源外殼。類型git remote -v
的cd C:\path\to\old\repository
顯示狀態以獲取讀取和遠程推遠程路徑。如果你的本地庫連接到遠程,它會顯示這樣的事情:
起源https://[email protected]/team-or-user-name/myproject.git(取) 起源https://[email protected]/team-or-user-name/myproject.git(推)
如果沒有連接,它可能只顯示origin
。
現在再次使用
git remote rm origin
檢查步驟4.從本地資源庫遠程倉庫它應該顯示origin
只,而不是獲取和推動路徑。
現在您的舊遠程存儲庫已斷開連接,您可以添加新的遠程存儲庫。使用以下連接到您的新存儲庫。
注意:如果您使用的是Bitbucket,您將首先在Bitbucket上創建一個項目。創建之後,Bitbucket將顯示所有必需的Git命令,以將您的存儲庫推送到遠程,這看起來與下一個代碼片段類似。但是,這也適用於其他存儲庫。
cd /path/to/my/repo # If haven't done yet
git remote add mynewrepo https://[email protected]/team-or-user-name/myproject.git
git push -u mynewrepo master # To push changes for the first time
就是這樣。
當我第一次使用Bitbucket設置時,我遇到了同樣的問題。
我的問題是,我需要改變自定義的東西的單詞來源。我使用了應用程序的名稱。因此:
git remote add AppName https://[email protected]/somewhere/something.git
您應該將遠程存儲庫的名稱更改爲其他名稱。
git remote add origin [email protected]:myname/oldrep.git
到
git remote add neworigin [email protected]:myname/oldrep.git
我認爲這應該工作。
是的,這些是用於存儲庫初始化和添加一個新的遠程。只是改名而已。
git remote rm origin
git remote add origin [email protected]:username/myapp.git
當您忘記進行第一次提交時也會發生這種情況。
METHOD1->
由於產地存在將其刪除。
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2->
人們也可以通過改變現有的遠程存儲庫URL - >遠程Git設置網址
如果要更新使用HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
如果您要更新爲使用SSH
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
如果嘗試更新不存在的遠程,您將收到錯誤消息。所以要小心。
METHOD3->
使用GIT中遠程重命名的命令到現有的遠程重命名。 現有的遠程名稱,例如,起源。
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
要驗證遠程的新名稱 - >
git remote -v
如果新的Git試試這個教程 - >
發出命令,$輸出>遠程Git -v顯示 – sykora 2009-08-03 11:50:17
[Github「fatal:remote origin already exists」]的可能重複](http://stackoverflow.com/questions/10904339/github-fatal-remo te-origin-already-exists) – 2014-02-05 14:52:16
如果您知道舊版本庫的URL,一個好方法是在新創建的版本庫底部使用**「從另一個版本庫導入」**。 – 2016-07-16 04:58:53