What will happen if I delete a branch on my git repo and someone try to push a commit to it?

Just a simple question that might seems dumb but I’m not a git expert!

Let’s say I delete a branch in local and push my delete. The branch will no longer be on my git repository.
But what’ll happen if then another user try to push a commit to this branch.

  • Reset all branches of a local repo to be the same as remote
  • Git Production / Development Release Branch
  • Sharing code between solutions in TFS
  • Git: List git branches, sort by (and show) date
  • What are the core concepts of git, github, fork & branch. How does git compare to SVN?
  • how does git svn dcommit determine where to commit to?
  • Will an error happen or will the branch be created again?

  • Publish Git repository to SVN
  • How to export all changed files between two Git commits in SourceTree?
  • How to launch and edit a file from Git using Notepad++?
  • Why is my Ruby Git script hook run with the wrong $PATH?
  • Which functions are missing in existing Emacs modules for work with git?
  • Undo-tree style git in terminal
  • 2 Solutions collect form web for “What will happen if I delete a branch on my git repo and someone try to push a commit to it?”

    I wasn’t sure, so I tested it out. It probably depends on permissions, but a new branch will be created in the target repository with the HEAD at the other user’s latest commit.

    Note that your branch is still in your git repo, and the question “Git: Recover deleted (remote) branch” explain how to find it back.

    That also confirm Explosion Pills’s answer: pushing a branch with the same name will re-create it on the upstream remote repo side with the new history.
    Since the upstream repo doesn’t contain that branch (after you pushed the ref :aBranch to delete it), said remote repo will create a new branch with the same name.

    Git Baby is a git and github fan, let's start git clone.