是否可以推送不在git中任何分支中的提交? [英] Is it possible to push a commit which is not in any branch in git?

查看:118
本文介绍了是否可以推送不在git中任何分支中的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本地我可以在没有任何分支活动的情况下进行提交,即在签出提交但没有分支之后.可以将不在任何分支中的该提交推送到远程吗?

Locally I can commit without any branch active, i.e. after checking out to a commit but not a branch. Is it possible to push this commit which is not in any branch to remote?

我只是在理论上想知道git将如何处理推送无分支"或只推送可能的分支.

I'm just wondering theoretically how would git handle pushing a "no-branch" or is pushing only possible with branches.

推荐答案

执行时

git push <remote> <source>:<destination>

<source>可以是提交,是的.

但是,<destination>有点棘手.从 doc 中获取

The <destination>, however, is a bit more tricky. Take it from the doc :

可以将任何类型的对象推送到refs/{tags,heads}/之外的任何名称空间.对于标记和提交,出于是否允许更新的目的,它们将被视为refs/heads/中的提交.

因此,基本上,您通常只推送到远程分支,但是可以,只要将提交从当前引用移到要推送的提交,就可以推送提交,这是一种快速的合并.

So basically, you mostly push only to remote branches, but yes you can push commits, as long as moving from their current ref to the one you're pushing is a fast-forward merge.

这篇关于是否可以推送不在git中任何分支中的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆