Sigfried
Sigfried

Reputation: 3100

is it dangerous to create a branch with same name as a deleted branch?

I've been working on a feature in a branch; call it 'foo'. I'm done for now and merging it into master and would like to delete it locally and remotely. But sometime in the future I may start working on this feature again and will be tempted to create a new branch also called 'foo'.

I don't think this will be a problem for me, but if someone else has their own copy of my current foo branch, and then they try to pull after the new foo branch has been created, will they get screwed up?

Upvotes: 55

Views: 33006

Answers (1)

SevenEleven
SevenEleven

Reputation: 2474

No, it's not a problem.

The behaviour would be the same, as if the branch has not been deleted: Git will try to merge (or rebase) them when someone pulls the new branch. If there are conflicts, they would be there in either case.

Branches are, simply, pointers to commits. If you delete a branch, and create another one with the same name later on another commit, this is the same as if you would reset it to that commit (git reset).

Upvotes: 66

Related Questions