我在我的硬盘上(本地)克隆的USB键上有一个repo(起源)。我将“起源”转移到NAS,并成功测试了从这里克隆。

我想知道我是否可以在“本地”设置中更改“起源”的URI,所以它现在将从NAS中拖动,而不是从USB键。

到目前为止,我可以看到两个解决方案:

把一切推到USB起源,然后将其复制到NAS(这意味着由于NAS起源的新承诺而付出很多工作);添加一个新的远程到“本地”并删除旧的(我担心我会打破我的历史)。


当前回答

移除远程

使用 git 远程 rm 命令从您的存储库中删除远程 URL。

    $ git remote -v
    # View current remotes
    > origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    > origin  https://github.com/OWNER/REPOSITORY.git (push)
    > destination  https://github.com/FORKER/REPOSITORY.git (fetch)
    > destination  https://github.com/FORKER/REPOSITORY.git (push)

    $ git remote rm destination
    # Remove remote
    $ git remote -v
    # Verify it's gone
    > origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    > origin  https://github.com/OWNER/REPOSITORY.git (push)

其他回答

如果你克隆了你的本地将自动组成,

远程 URL 在那里它被克隆。

您可以使用 git remote -v 查看。

如果你想改变它,

git remote set-url origin https://github.io/my_repo.git

这里,

起源 - 你的分支

如果你想重写现有分支,你仍然可以使用它......它会重写你的现有分支......它会

git remote remove url
and 
git remote add origin url

為你...

此分類上一篇: git remote set-url {name} {url}

git remote set-url origin https://github.com/myName/GitTest.git

导航到本地存储库的项目根,并检查现有远程:

git remote -v

如果您的存储库使用SSH,您会看到这样的东西:

> origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin  git@github.com:USERNAME/REPOSITORY.git (push)

如果您的存储库使用 HTTPS,您会看到这样的东西:

> origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin  https://github.com/USERNAME/REPOSITORY.git (push)

取决于 git 远程 -v 的输出,您可以以以下方式更改 URL:

在 SSH 的情况下,您可以从 REPOSITORY.git 更改 URL 到 NEW_REPOSITORY.git 如下:

$ git remote set-url origin git@github.com:USERNAME/NEW_REPOSITORY.git

而在 HTTPS 的情况下,您可以从 REPOSITORY.git 更改 URL 到 NEW_REPOSITORY.git 如下:

$ git remote set-url origin https://github.com/USERNAME/NEW_REPOSITORY.git

注意: 如果您已更改了 GitHub 用户名,您可以按照上述相同的过程更新与您的存储库相关的用户名的更改。

正如我们在这里看到的那样,

$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master

查看您的特权

在我的情况下,我需要检查我的用户名

我有兩個或三個存储庫,有清潔的信件。

问题是我的许可我有两个私人 git 服务器和存储库

这个第二个帐户是该新 repo 的管理员,第一个是我的默认用户帐户,我应该允许首先