0

I tried to push changes in my local branch(local_dev) to a remote branch(develop), I used below command, but it gave me an unexpected message after executing the command.

$ git push origin local_dev :develop

message after command execution:

Counting objects: 1941, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (838/838), done.
Writing objects: 100% (1378/1378), 265.47 KiB | 0 bytes/s, done.
Total 1378 (delta 604), reused 863 (delta 257)
remote: error: refusing to delete the current branch: refs/heads/develop
To https://github.com/MyCompany/MyProject.git
 * [new branch]      local_dev -> local_dev
 ! [remote rejected] develop (deletion of the current branch prohibited)
error: failed to push some refs to 'https://github.com/MyCompany/MyProject.git'

Any suggestions on this why this should happen?

Thanks.

Nirmal Mangal
  • 812
  • 1
  • 12
  • 26
  • 1
    possible duplicate of [Deleting remote master branch, refused due to being current branch](http://stackoverflow.com/questions/14040754/deleting-remote-master-branch-refused-due-to-being-current-branch) – Gordon Gustafson May 28 '14 at 17:54
  • 1
    It may look like a duplicate, however I was not trying to delete a branch, just wanted to push my changes to another branch. Glad I didn't have access to delete that branch. – Nirmal Mangal May 28 '14 at 18:15

1 Answers1

1

You have a space in the refspec. It should be this:

git push origin local_dev:develop

and not this

git push origin local_dev :develop

Because that space is there, you're giving git push two refspecs, not one. The first spec says "push local_dev to the remote with the name local_dev". The second spec says :develop, and since the left-hand side of : is empty, it means "delete the remote develop branch". That's why you get this last line in your git push output:

! [remote rejected] develop (deletion of the current branch prohibited)

For more information on deleting branches with :<branch> syntax, please read,