簡體   English   中英

git 本地存儲庫與我的 github 帳戶分離

[英]git local repository is detached from my github account

希望不是 TLDR 我在本地 PC 上有一個源項目。 它工作正常,我可以編輯、添加、提交、推送; 我將本地文件夾移動到稍微短一點的路徑(從 d:\\users\\me\\documents\\github\\crypto\\intro\\Exercise1.1 到 d:\\users\\me\\source\\repos\\crypto\\intro\\Exercise1.1)不,它沒有連接到遠程https://github.com/masmowa/crypto

這是 git remote 所說的

PS D:\Users\Mark\Source\Repos\Crypto> git remote -v                                                                     PS D:\Users\Mark\Source\Repos\Crypto> pushd .\intro\Exercise1.1\                                                        PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git remote -v                                                   IntroToCryptoEx https://github.com/masmowa/crypto/IntroToCryptoEx (fetch)
IntroToCryptoEx https://github.com/masmowa/crypto/IntroToCryptoEx (push)
introToCryptoEx origin (fetch)
introToCryptoEx origin (push)
origin  https://github.com/masmowa/crypto/IntroToCryptoEx (fetch)
origin  https://github.com/masmowa/crypto/IntroToCryptoEx (push)
PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch                                                      * master                                                                                                                PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch --al                                                 * master                                                                                                                PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch --all                                                * master                                                                                                                PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git help branch                                                 PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch -r                                                   PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch -r -v                                                PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1>
...
PS D:\Users\Mark\Source\Repos> code .\.gitattributes                                                                    PS D:\Users\Mark\Source\Repos> pushd .\Crypto\intro\Exercise1.1\                                                        PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git remote -v                                                   IntroToCryptoEx https://github.com/masmowa/crypto/IntroToCryptoEx (fetch)
IntroToCryptoEx https://github.com/masmowa/crypto/IntroToCryptoEx (push)
introToCryptoEx origin (fetch)
introToCryptoEx origin (push)
origin  https://github.com/masmowa/crypto/IntroToCryptoEx (fetch)
origin  https://github.com/masmowa/crypto/IntroToCryptoEx (push)
PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git branch                                                      * master
PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git status                                                      On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        AnalyzeCryptoMessage/AnalyzeCryptoMessage/Notes/wordsL4.csv
        AnalyzeCryptoMessage/AnalyzeCryptoMessage/Notes/wordsL4v2.csv
        AnalyzeCryptoMessage/AnalyzeCryptoMessage/Notes/wordsL5.csv
        AnalyzeCryptoMessage/AnalyzeCryptoMessage/output/DecryptMessage-output-20200316-164547-1.txt

nothing added to commit but untracked files present (use "git add" to track)
PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git push                                                        fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

PS D:\Users\Mark\Source\Repos\Crypto\intro\Exercise1.1> git push --set-upstream origin master                           remote: Not Found
fatal: repository 'https://github.com/masmowa/crypto/IntroToCryptoEx/' not found 

您的遠程 URL 指向https://github.com/masmowa/crypto/IntroToCryptoEx ,但所有 GitHub 存儲庫都有兩個路徑組件。 這意味着您的存儲庫可能是https://github.com/masmowa/crypto ,也可能在其他地方,但這不是您指定的。

要更改遙控器,您可以編寫如下內容:

$ git remote set-url origin https://github.com/masmowa/crypto

請注意,如果您嘗試推送到存儲庫的子目錄中,那將不起作用,因為 Git 不允許這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM