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.

  • Git push everything to new origin
  • Git: how can git/linux maintainers maintain so many branches
  • How are git tags different from git branches?
  • Referencing composer version on branched **and** tagged repository
  • Git: is there a quicker way to merge from one branch to multiple branches than doing each one serially?
  • Accessing a repo in Netbeans with git
  • Will an error happen or will the branch be created again?

  • Seeking a naming convention for multiple Git repos under a single Team Project
  • gitworkflows - how exactly to graduate a branch?
  • git add --patch with difftool
  • Gitolite on Dreamhost
  • Can a lightweight tag be converted to an annotated tag?
  • Extracting only open issues from github api without any pull request using ruby on rails
  • 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.