push an 'unchecked out' branch

Git

Git Problem Overview


I want to push a branch (not the current) without having to check it out first, how can I achieve that ?

this is how I'd do:

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

but checking out feature can cause conflicts, can't I just push another branch than the current one ?

Git Solutions


Solution 1 - Git

Simply:

git push origin feature:feature

Or shorter:

git push origin feature

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBiAiBView Question on Stackoverflow
Solution 1 - GittrojanfoeView Answer on Stackoverflow