我有一仓库的(来源)在一个u盘,我的克隆在我的硬盘驱动(当地的).我移动的"来源"一NAS和成功试验性克隆它从这里。

我想知道如果我可以改变的URI"原籍国"的"地方",因此它现在将拉从NAS,而不是从USB关键。

现在,我可以看到两个方案:

  • 推一切usb orign,并复制到NAS再次(暗示了很多的工作由于新的承诺nas源);

  • 添加一个新的远程"地方"并删除旧的一个(我怕我会伤了我的历史)。

有帮助吗?

解决方案

你可以

git remote set-url origin new.git.url/here

(见 git help remote)或者你可以编辑 .git/config 和变化的网址。你不是在任何失去的危险的历史,除非你做一些非常傻的(如果你担心,只要一份你仓库中,由于你的仓库 你的历史。)

其他提示

git remote -v
# View existing remotes
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL

git remote -v
# Verify new remote URL
# origin  https://github.com/user/repo2.git (fetch)
# origin  https://github.com/user/repo2.git (push)

变化的一个偏远的地址

改变主为个混源服务器

自: http://pseudofish.com/blog/2010/06/28/change-host-for-a-git-origin-server/

希望这不是你需要做的。服务器,我一直在使用合作的几个导具有域名期。这就意味着找到一种方式迁移的地方储存库以回去同步。

更新:由于@mawolf指出有一个简单的方法与最近的git版本(post月、2010年):

git remote set-url origin ssh://newhost.com/usr/local/gitroot/myproject.git

见人页的详细信息。

如果你在一个旧版本,然后试试这个:

作为一个警告,这一工作仅仅因为它是相同的服务器,只是以不同的名称。

假设新的主机 newhost.com, 和旧是 oldhost.com, ,变化是相当简单的。

编辑 .git/config 文件在您的工作目录。你应该看到的东西,如:

[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://oldhost.com/usr/local/gitroot/myproject.git

改变 oldhost.comnewhost.com, 该文件保存和你完成。

从我的有限测试(git pull origin; git push origin; gitx)似乎一切都在顺序。是的,我知道这是不好的形式乱}类型的内部。

git remote set-url origin git://new.location

(或者,打开 .git/config, ,你看 [remote "origin"], 和编辑 url = 线。

你可以检查它的工作通过审查的遥控器:

git remote -v
# origin  git://new.location (fetch)
# origin  git://new.location (push)

下一次你的推动,你就必须指定新的上游分支,例如:

git push -u origin master

参见: 审查:变化的一个偏远的地址

交换网址的远程

打开端。

Ist步骤:-改变目前的工作目录到您本地的项目。

第2步:-列表中现有的远程控制为了获得姓名的远程,你想要改变。

git remote -v

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

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

改变你的远程的网址从HTTPS SSH与从初的远程设置网址的命令。

第3步:- git remote set-url origin git@github.com:USERNAME/REPOSITORY.git

第4步:-现在验证远程网址已变更。

git remote -v 验证新的远程URL

origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
origin  git@github.com:USERNAME/REPOSITORY.git (push)
  1. 删除原籍国采用命令gitbash git远程rm来源
  2. 现在添加新的原产地使用gitbash git遥远的添加产地 (复制URL HTTP从项目库中的位桶) 做

git远程设置-url{名}{url}

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

检查git远程连接:

git remote -v

现在,设置地储存库的远程文件

git remote set-url origin https://NewRepoLink.git

现在让它在上游或推动使用下列代码:

git push --set-upstream origin master -f

如果你克隆的当地将自动包括,

远程网址,它得到克隆。

你可以检查它使用 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 origin https://NewRepoLink.git

输入凭证

我的工作:

git remote set-url origin <project>

如果你使用TortoiseGit然后按照以下步骤:

  1. 去你的当地结算文件夹和正确的点击进入 TortoiseGit -> Settings
  2. 在左侧的窗格选择 Git -> Remote
  3. 在右边的窗格中选择 origin
  4. 现在改变 URL 文本框值在任何新的远程存储库

你的分行和所有当地承诺将保持不变,你可以继续工作,如你之前。

你有很多方法可以做到的是:

控制台

git remote set-url origin [Here new url] 

只是确保你已经打开它在一个地方,一个储存库。

Config

它被放置。git/配置(相同的文件夹中的储存库)

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = [Here new url]  <------------------------------------
...

TortoiseGit

Step 1 - open settings

Step 2 - change url

然后就编辑的网址。

SourceTree

  1. 点击"设定"的按钮打开仓库设置窗口。

  2. 点击"添加"添加一个远程仓库的路径的资料库。"远程细节"窗口将开放。

  3. 输入一个名称为偏远的路径。

  4. 进入网址/路为远程数据库

  5. 输入的用户名的托管服务的远程存储库。

  6. 点击"OK"添加遥远的道路。

  7. 回仓库设置窗口,点击"OK"。新的远程路径应该加上储存库。

  8. 如果你需要编辑一个已经加入偏远的道路,只要点击的"编辑"按钮。你应该针对"远程细节"窗口,在这里你可以编辑细节(URL/Path/主机类型)远程的道路。

  9. 除远程存储库的道路,点击的"删除"键

enter image description here

enter image description here

ref. 支持

enter image description here

故障排除:

你可能会遇到这些错误时,试图改变一个遥远。没有这样的远程'[name]'

这个错误意味着遥你试图改变并不存在:

git远程设置-url sofake https://github.com/octocat/Spoon-Knife 致命的:没有这样的远程'sofake'

检查你已正确输入远程名称。

参考: https://help.github.com/articles/changing-a-remote-s-url/

改变的远程仓URI git@github.com 而不是 https://github.com

git remote set-url origin git@github.com:<username>/<repo>.git

这样做的好处是,你可以做的 git push 自动 当你使用 ssh剂 :

#!/bin/bash

# Check ssh connection
ssh-add -l &>/dev/null
[[ "$?" == 2 ]] && eval `ssh-agent`
ssh-add -l &>/dev/null
[[ "$?" == 1 ]] && expect $HOME/.ssh/agent

# Send git commands to push
git add . && git commit -m "your commit" && git push -u origin master

把脚本文件 $HOME/.ssh/agent 让它运行 ssh-add 使用 希望 如下:

#!/usr/bin/expect -f
set HOME $env(HOME)
spawn ssh-add $HOME/.ssh/id_rsa
expect "Enter passphrase for $HOME/.ssh/id_rsa:"
send "<my_passphrase>\n";
expect "Identity added: $HOME/.ssh/id_rsa ($HOME/.ssh/id_rsa)"
interact
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top