git是否直接将URL推送到URL而不需要远程?

And*_*ohr 3 git

我知道我可以使用URL直接从远程存储库拉到当前分支,而不必像这样将存储库添加为远程库:

git pull git://github.com/them/repository.git theirbranch
Run Code Online (Sandbox Code Playgroud)

快速签出拉取请求非常方便。

现在,我想知道是否有可能进行相同的推送(假设我具有所需的存储库访问权限)。我尝试了以下操作,但不起作用:

git push git://github.com/them/repository.git theirbranch
Run Code Online (Sandbox Code Playgroud)

我知道我可以通过添加URL git remote add,然后将其推送到名为remote 的URL ,但是为一次性推送创建配置似乎过头了。我觉得应该有可能,但我根本想不出正确的语法,所有示例始终使用命名的遥控器。

kgr*_*ffs 11

推送到远程分支当然是可能的,但您可能需要指定本地分支名称,并使用 HTTP URI,以便这样做。

假设您维护一个项目并希望在合并之前对拉取请求进行一些调整。您首先拉动功能分支:

$ git checkout -b username-featurename master
$ git pull git://github.com/username/projectname.git featurename
Run Code Online (Sandbox Code Playgroud)

进行更改后,您可以直接推送到原始功能分支,假设所有者已授予您适当的权限。您可能只被允许使用 HTTP URI 执行此操作,并且还必须在 refspec 中指定您的本地分支名称:

$ git push https://github.com/username/projectname.git username-featurename:featurename
Run Code Online (Sandbox Code Playgroud)


Lig*_*der 5

根据push的git文档,可以将存储库指定为有效的git url或对已保存的远程的引用。

这将适用于远程URL:

ssh://[user@]host.xz[:port]/path/to/repo.git/
git://host.xz[:port]/path/to/repo.git/
http[s]://host.xz[:port]/path/to/repo.git/
ftp[s]://host.xz[:port]/path/to/repo.git/
Run Code Online (Sandbox Code Playgroud)

或本地存储库:

/path/to/repo.git/
file:///path/to/repo.git/
Run Code Online (Sandbox Code Playgroud)

并支持所有常用配件(用户名,端口)。