git - 是否可以推送不在 git 任何分支中的提交?

标签 git git-push

在本地,我可以在没有任何分支处于事件状态的情况下提交,即在 checkout 提交但不 checkout 分支之后。是否可以将不在任何分支中的提交推送到远程?

编辑:我只是想知道理论上 git 将如何处理推送“无分支”或仅推送分支。

最佳答案

当你这样做的时候

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

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

<destination> , 然而,有点棘手。从doc中取出:

It’s possible to push any type of object to any namespace outside of refs/{tags,heads}/. In the case of tags and commits, these will be treated as if they were the commits inside refs/heads/ for the purposes of whether the update is allowed.

所以基本上,您主要只推送到远程分支,但是是的,您可以推送提交,只要从当前引用移动到您正在推送的引用是快进 merge 。

关于git - 是否可以推送不在 git 任何分支中的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55130311/

相关文章:

git - 为什么我的远程 Git 存储库在推送到它之后有未提交的更改?

git - 如何从存储库 checkout 分支

git - 有没有办法跟踪 Atlassian Crucible 中分支的 merge 前和 merge 后代码审查

xcode - Xcode4中这个Git是什么?

git - 我可以为本地分支定义多个上游分支吗?

ios - Git 上的 Push 错误,然后是 Pull 和 Workspace 上的错误

php - 由于子模块,Heroku 不会接受推送

git commit挂了,怎么办?

git - 将 pushurl 添加到 git 子模块

git - 如何通过ubuntu更新github中的文件