tj / tj/git-extras

git delete-branch deleted wrong branch

Open
#638 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
18.1k
Forks
1.2k
Avg merge
5d 17h
Merged PRs (30d)
1

Description

$ git delete-branch test
Deleted branch test (was e76dbe9).
error: remote-tracking branch './test' not found.
To .
 - [deleted]         work

As you can see above, I wanted to delete my test branch which I created with:

git checkout --track -b test

After running that command I went back to master branch and did the git delete-branch test as above. I Believe that because I did not create a remote it must have confused it somehow.

Luckily, I was able to retrieve my stuff back from my work branch though, so that is good at least.

I realize now that what I was doing doesn't really make any sense, but I still feel like it probably shouldn't and gone to delete a completely different branch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported sequence with git checkout --track -b test, then git delete-branch test, and inspect the git delete-branch entry point. Confirm which branch is removed when the requested branch has no remote, and consider the work complete when deleting a local-only branch cannot remove a different branch; add or run the relevant command-level checks if the project provides them.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.