Reputation: 125
Created a GitHub repository for a PyCharm Project by using the VCS option in PyCharm. After that, another branch was created with the name Pytest-bdd. Now the repository itself is manually deleted from Github. But when the command git branch -a
is run from PyCharm terminal it shows the below options
* master
remotes/github/Pytest-bdd
remotes/github/master
Why does it show remote repository when it does not exist in Github anymore.
Upvotes: 0
Views: 435
Reputation: 488453
If the entire repository is deleted, you should delete the remote:
git remote remove github
This also removes all of the remote-tracking names that go with that remote.
When working with Git, you often work with two, or even more than two, Git repositories. Each repository exists in some location on some computer. A file or other resource that exists on some computer can often be named using a Uniform Resource Locator or URL.
So if you have a Git repository on GitHub under the name https://github.com/user/repo.git
, for instance, this is a URL for this repository. You could type this string in every time you want your own Git, on your own computer, to call up the Git on GitHub that is in charge of that repository over on GitHub. But it's easier to type in a short name:
git fetch origin
than the longer one:
git fetch https://github.com/user/repo.git
This short name, origin
, is a remote. A remote, in Git, stores a URL. It can do more, but storing a URL is its most basic job.
When you first clone some existing repository, Git adds the remote name origin
to hold the URL you used in your git clone
command. So it's pretty common for your own Git, on your own computer, to have an origin
.
You can add more remotes. First, you need to come up with a name you want to use, such as hubert-blaine-wolfeschlegelsteinhausenbergerdorff-sr
or fred
or github
or upstream
. Shorter names are probably better, but you should use one that means something to you. Next, you need a URL at which some Git repository answers the Internet-phone when you call it up. You then use git remote add
to add the remote-and-URL pair:
git remote add upstream https://github.com/user2/repo2.git
for instance.
When you use git fetch
, you have your Git call up some other Git. If you use a remote to name the other Git, your Git fishes the URL out of your Git configuration files and uses that to phone-up the other Git. The other Git will list, for your Git, its branch names. Your Git, at the end of the git fetch
session, will create in your repository, a series of similar names.
To avoid stepping on your branch names, your Git creates their branch names, in your repository, using remote-tracking names. To turn their branch name into your remote-tracking name, your Git sticks your remote name, such as origin
or upstream
, in front of their branch name. So their master
becomes your origin/master
, or upstream/master
, or github/master
.
Internally, all of these names have long (or full name) forms: instead of master
, for instance, your own master
branch is really refs/heads/master
. The origin/master
here is short for refs/remotes/origin/master
. Git normally takes away these prefixes so that you do not have to see them or type them in.
When you run git branch -r
, your Git will list these remote-tracking names. When you run git branch
or git branch -l
, your Git will list your branch names. When you use git branch -a
, your Git will list both, but this time, instead of shortening remote-tracking names to, e.g., origin/master
, your Git will shorten them to remotes/origin/master
.
This is what you show in the image you put up at the top of your question. The branch name master
—an original name in your repository—is in green; the remote-tracking names—their branch names, but modified by your Git to fit in your repository—are in red.
Since the repository on GitHub is entirely gone, all these red-text remote-tracking names are useless now. You can delete them, one by one, from your own Git repository. But since the repository on GitHub is entirely gone, the remote name github
itself is also useless. Rather than painstakingly deleting each remote-tracking name, and leaving the remote itself behind, you can just delete the remote entirely. Deleting the remote deletes all of your own Git's remote-tracking names copied from that remote, so one delete will do everything.
Upvotes: 1
Reputation: 6698
Those are "remote-tracking branches" https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches. They remember what the "remote looked like as of the last time you communicated with it," meaning that they don't get updated in real time by what you do to the remote through other means, e.g. by deleting the repo on GitHub.
If you want to clean this stuff up from your local repository, do these two things:
Upvotes: 1