2

I have a project with a friend with only one branch, master. My friend last worked on the project and I fetched (git fetch) his work just to have a look. This created a branch called origin/master:

Project ps1$ git branch -a
  * master
    remotes/origin/master

I checked it out (git checkout origin/master) and I don't agree with everything that was done, so I don't want to merge now. I'm going to let my friend work more on it. I tried to delete this fetched branch just to clean up, using either

git branch -d remotes/origin/master

or

git branch -d origin/master

but it said the branch was not found in both cases. How do I get rid of this branch (should I even do this?)?

Ben
  • 167
  • 2
  • 10
  • 2
    Possible duplicate of [cleaning up old remote git branches](https://stackoverflow.com/questions/3184555/cleaning-up-old-remote-git-branches) – Mureinik Dec 28 '17 at 21:09
  • Just don't use `-a`. That is showing you branches in your friend's repo. If you have your friend's branch setup as a remote and don't want to see anything, do a `git remote remove` – William Pursell Dec 28 '17 at 21:18

1 Answers1

1

git branch -rd origin/master should work.

From the documentation:

Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again.

mkrieger1
  • 10,793
  • 4
  • 39
  • 47
  • Thanks! So this will only delete my local remote-tracking branch `origin/master` right? This won't affect the remote repo at all? – Ben Dec 28 '17 at 21:48