tir38
tir38

Reputation: 10441

delete local branch called "remote"

I've done something incredibily stupid. I figured I should ask before I tried to "fix" it and accidentally make things worse.

I tried to list all remote branches in my git repo:

git branch remote

Obviously this isn't the correct command. Instead of listing remote branches, I created a local branch called remote. I should have done:

git branch -r

Can I just remove this branch with:

git branch -d remote

Will this have any effect on my remote branches? I don't want to accidentally delete anything on the remote side.

Upvotes: 2

Views: 227

Answers (2)

user41871
user41871

Reputation:

Yes,

git branch -d remote

Take a look:

MYHOST:git wwheeler$ cd seiso/
MYHOST:seiso wwheeler$ git branch
* master
  trunk
MYHOST:seiso wwheeler$ git branch remote
MYHOST:seiso wwheeler$ git branch
* master
  remote
  trunk
MYHOST:seiso wwheeler$ git branch -d remote
Deleted branch remote (was 15dc59f).
MYHOST:seiso wwheeler$ git branch
* master
  trunk
MYHOST:seiso wwheeler$ 

Upvotes: 3

Mark Dominus
Mark Dominus

Reputation: 1808

I have made that mistake too. One easy thing to do is rm .git/refs/heads/remote.

Much of the git repository structure is straightforward, and you can learn a lot by poking around in it.

Upvotes: 1

Related Questions