如何重置计算机终端中的github设置(切换github配置文件)

如何重置计算机终端中的github设置(切换github配置文件),git,macos,github,Git,Macos,Github,我一直在试图用git解决问题。我不断收到(或者应该说是“gitting”)错误,这些错误与试图将git提交推送到不再存在的repo的终端有关,我正在尝试将提交发送到新的github配置文件 所以我只想以某种方式将终端git设置更改为reset,以便重新设置它。我如何重新设置它,让它看起来像我从未设置过一样?我已经筋疲力尽了 有没有办法完成重置或擦除和卸载,然后重新安装git。我尝试了当前两个答案的建议,但仍然不断出错 首先将cd放入git文件夹 通过git remote(只有origin)显示此

我一直在试图用git解决问题。我不断收到(或者应该说是“gitting”)错误,这些错误与试图将git提交推送到不再存在的repo的终端有关,我正在尝试将提交发送到新的github配置文件

所以我只想以某种方式将终端git设置更改为reset,以便重新设置它。我如何重新设置它,让它看起来像我从未设置过一样?我已经筋疲力尽了

有没有办法完成重置或擦除和卸载,然后重新安装git。我尝试了当前两个答案的建议,但仍然不断出错

  • 首先将
    cd
    放入git文件夹
  • 通过
    git remote
    (只有
    origin
    )显示此git文件夹的远程存储库的所有短名称-或通过
    git remote-v
    (详细)显示所有短名称及其完整URL
  • 通过git remote rm origin
    或
    通过
    git remote rename origin old_origin
    将其重命名为
    old_origin
    。 检查您通过
    git remote-v
    所做的更改
  • 在新的github配置文件(
    )中创建名为
    假设用户名是
    mynewme
    ,repo是
    mynewrepo
  • 通过git remote add为这个git文件夹添加新的repogit://github.com//.git,这里-现在命名新的回购协议
    来源
    ,但其他简称也可以。。。
    git远程添加源git://github.com/mynewme/mynewrepo.git
    。 通过添加具有不同短名称的不同回购协议,您可以并行持有多个git回购协议,并在向它们推/拉/更新本地git时区分它们
  • 推送至您的新回购
    git-push
    ,这里,因为我们用缩写名
    origin
    命名为repo,这也是众所周知的
    git-push-origin主机
    , 您可以将其缩短为
    git push
    (因为
    origin
    master
    是默认设置)
  • 由于您的新repo被称为
    origin
    ——这是git文件夹的默认远程repo

    这里再次显示所有命令:

    cd /path/to/my/git/folder # your path to your git folder!
    git remote -v # show all remote repo addresses with shortname at beginning
    git remote rm origin # or: git remote rename origin old_origin
        # you can rename it later back or remove repos with these commands!
    git remote -v # check changes!
    git remote add origin git://github.com/mynewme/mynewrepo.git 
        # new shortname and new repo's address
    git remote -v # check adding!
    git push origin master # or just: git push
        # your first push to update your new remote repo with the current content
    
  • 首先将
    cd
    放入git文件夹
  • 通过
    git remote
    (只有
    origin
    )显示此git文件夹的远程存储库的所有短名称-或通过
    git remote-v
    (详细)显示所有短名称及其完整URL
  • 通过git remote rm origin
    或
    通过
    git remote rename origin old_origin
    将其重命名为
    old_origin
    。 检查您通过
    git remote-v
    所做的更改
  • 在新的github配置文件(
    )中创建名为
    假设用户名是
    mynewme
    ,repo是
    mynewrepo
  • 通过git remote add为这个git文件夹添加新的repogit://github.com//.git,这里-现在命名新的回购协议
    来源
    ,但其他简称也可以。。。
    git远程添加源git://github.com/mynewme/mynewrepo.git
    。 通过添加具有不同短名称的不同回购协议,您可以并行持有多个git回购协议,并在向它们推/拉/更新本地git时区分它们
  • 推送至您的新回购
    git-push
    ,这里,因为我们用缩写名
    origin
    命名为repo,这也是众所周知的
    git-push-origin主机
    , 您可以将其缩短为
    git push
    (因为
    origin
    master
    是默认设置)
  • 由于您的新repo被称为
    origin
    ——这是git文件夹的默认远程repo

    这里再次显示所有命令:

    cd /path/to/my/git/folder # your path to your git folder!
    git remote -v # show all remote repo addresses with shortname at beginning
    git remote rm origin # or: git remote rename origin old_origin
        # you can rename it later back or remove repos with these commands!
    git remote -v # check changes!
    git remote add origin git://github.com/mynewme/mynewrepo.git 
        # new shortname and new repo's address
    git remote -v # check adding!
    git push origin master # or just: git push
        # your first push to update your new remote repo with the current content
    

    除了@gwang jin kim的答案,您还可以直接编辑
    (REPO_DIR)/.git/config
    文件

    如果使用首选编辑器打开该文件,您将看到
    [远程“源代码”]
    部分

    在该部分中,修改新git url的
    url=…
    (您可以通过访问github web上的新repo->克隆或下载来获取此url)

    完成此操作后,
    git push origin master
    将推送到新的上游(repo)


    但是,根据新的存储库设置,您可能会遇到
    推送被拒绝…
    错误。在这种情况下,如果您认为新回购协议的预先存在的提交无关紧要,您可以添加
    -f(或--force)
    选项来删除预先存在的提交。

    除了@gwang jin kim的答案,您还可以直接编辑
    (repo_DIR)/.git/config
    文件

    如果使用首选编辑器打开该文件,您将看到
    [远程“源代码”]
    部分

    在该部分中,修改新git url的
    url=…
    (您可以通过访问github web上的新repo->克隆或下载来获取此url)

    完成此操作后,
    git push origin master
    将推送到新的上游(repo)

    但是,根据新的存储库设置,您可能会遇到
    推送被拒绝…
    错误。在这种情况下,如果您认为新回购协议的预先存在的提交无关紧要,您可以添加
    -f(或--force)
    选项来删除预先存在的提交