推动“未签出”分支


86

我想先推送一个分支(而不是当前分支),而不必先将其签出,如何实现呢?

这就是我要做的:

#currently in master
git checkout feature
git push origin feature
git checkout master

但是签出功能会导致冲突,我不能只推送当前分支以外的另一个分支吗?


有不同的解决方案可能涉及:stackoverflow.com/questions/51342767/...
迅扬

4
请注意,这种做法存在风险:如果您有推钩,它们将在当前分支而不是您要推的分支上运行。
Xun Yang

Answers:


148

只是:

git push origin feature:feature

4
有必要写feature:feature还是可以写git push origin feature
Glemi

4
@Glemi不,它是可选的;检查手册中的refspec位。
trojanfoe19年

它对我不起作用,并说错误:src refspec dev与任何//错误都不匹配:无法推送一些裁判
toioioi
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.