Is it possible in git to create a new, empty remote branch without pushing? --- This doesn't work for me because even if I am using --orphan command, I can't push it to a remote.
Asked
Active
Viewed 853 times
1 Answers
0
Since it is a new local branch (created with --orphan
), you would still need to push it after having created it:
git -c "push.default=current" push -u origin newBranch
See "Why do I need to explicitly push a new branch?".
For the -c
option, see "Is they a way to set push.default
to current
only for the current push".
-
The problem is not with the Push.The problem is with creating "empty" branch , without any content on a remote repository which has many branches. Tried using this : git commit –allow-empty -m “Empty Branch” But doesn't seem to work. – Snigdha Gayatri Jul 27 '15 at 10:42
-
@SnigdhaGayatri well, an orphan branch created locally, and then push will create an empty branch on the remote repo. – VonC Jul 27 '15 at 10:43
-
@SnigdhaGayatri what is the exact command you have typed, and the exact error message you got? – VonC Jul 27 '15 at 10:48
-
git checkout --orphan newBranch ; git push origin newBranch ---> "src refspec newBranch does not match any. " – Snigdha Gayatri Jul 27 '15 at 10:59
-
@SnigdhaGayatri try: `git -c "push.default=current" push -u origin newBranch`. I have edited my answer accordingly. – VonC Jul 27 '15 at 11:00
-
The answer didn't actually work for me, so I just committed the .gitignore file and then just did a normal push `git push --set-upstream origin newBranch` and it did work. – Utsav Preet Mar 23 '19 at 19:28