When I list my branches with git branch -a
, git shows me remote branches I can't actually find on my remote(gitlab). I tried to checkout and track those branches, and to my big surprise, git did it. But when I do for example git push origin :branch_name
, git says that the remote ref does not exist, thus proving that I do not have those branches in my remote. Hence I have a question, are those branches stored in some kind a local cache? And if yes, how to clear it?
The Git cache is within a file named index within the . git directory. The command will give you an output showing the file type, version, and the number of entries inside the Git cache file.
Usually, you want to clear your Git cache because you added new entries in your gitignore files and you want them to be taken into account. The easiest way to clear your Git cache is to use the “git rm” command with the “–cached” option. You can choose to remove one file or to remove an entire working directory.
The –cached flag lets you delete a file from a Git repository without deleting it on your file system.
Use git fetch -p
to prune your local caches
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With