Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何覆盖git pushRemote?_Git - Fatal编程技术网

如何覆盖git pushRemote?

如何覆盖git pushRemote?,git,Git,我有一个Git回购协议,其中有一个分支机构my_branch,还有一个远程origin,其中有一个同名分支机构。启用my_branch时,git push origin my_branch按预期工作,但git push返回 fatal: 'my_branch' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the cor

我有一个Git回购协议,其中有一个分支机构
my_branch
,还有一个远程
origin
,其中有一个同名分支机构。启用
my_branch
时,
git push origin my_branch
按预期工作,但
git push
返回

fatal: 'my_branch' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
看着和,我不明白为什么这行不通。我怀疑原因可能是我的
.git/config
中的这一行:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/user/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    pushurl = https://github.com/user/repo.git
[branch "other"]
    remote = origin
    merge = refs/heads/master
    pushRemote = origin
[branch "my_branch"]
    remote = origin
    merge = refs/heads/my_branch
    pushRemote = my_branch     <------
[core]
repositoryformatversion=0
filemode=true
裸=假
logallrefupdates=true
ignorecase=true
预复合代码=真
[远程“源”]
url=https://github.com/user/repo.git
fetch=+refs/heads/*:refs/remotes/origin/*
pushurl=https://github.com/user/repo.git
[分支机构“其他”]
远程=原点
合并=参考/头/主
pushRemote=原点
[分行“我的分行”]
远程=原点
合并=引用/标题/我的分支
pushRemote=我的分支
我认为Git正在寻找一个名为my_branch
的远程分支,对吗

是的,他说:

在分支
上时,它会覆盖
branch..remote
以进行推送

更有用的是,他说:

在分支
上时,它告诉
git fetch
git push
从哪个远程设备获取/推送到哪个远程设备

因此,是的,此设置应指定远程名称,而不是分支名称

如果是,我如何覆盖/删除此项

最简单的方法是编辑该文件。您可以将该设置的值更改为
origin
,或者因为您希望它与同一分支的
remote
设置相同,所以只需删除
pushRemote
行即可

如果你担心弄乱格式,你也可以使用它来为你编辑文件

我认为Git正在寻找一个名为my_branch的远程分支,对吗

是的,他说:

在分支
上时,它会覆盖
branch..remote
以进行推送

更有用的是,他说:

在分支
上时,它告诉
git fetch
git push
从哪个远程设备获取/推送到哪个远程设备

因此,是的,此设置应指定远程名称,而不是分支名称

如果是,我如何覆盖/删除此项

最简单的方法是编辑该文件。您可以将该设置的值更改为
origin
,或者因为您希望它与同一分支的
remote
设置相同,所以只需删除
pushRemote
行即可


如果您担心弄乱格式,也可以使用它来为您编辑文件。

–听起来您不想这样。您只需删除gitconfig中的这些行即可听起来你不想那样。您只需删除gitconfig中的那些行即可。
gitconfig
以“正确的方式”进行编辑,这对一些初学者来说有时是一个挑战。我个人认为学习如何编辑文件是值得的,但也有人建议总是使用
git config
来编辑文件。@torek我可以理解这一道理。就我个人而言,我发现git config的参数比文本文件格式更令人困惑,但人们的经历各不相同。我对最后一句话做了一些修改。
git config
以“正确的方式”进行编辑,这对一些初学者来说有时是一个挑战。我个人认为学习如何编辑文件是值得的,但也有人建议总是使用
git config
来编辑文件。@torek我可以理解这一道理。就我个人而言,我发现git config的参数比文本文件格式更令人困惑,但人们的经历各不相同。我把最后一句话改写了一点。