How to update GCC version via Homebrew?
The standard command brew upgrade gcc should work. The formula for gcc points to the latest version. You can also install a specific version, ex. brew install gcc@10.

I did this, but after upgrading when I checked the gcc version (using gcc --version), it shows me the Clang version. What’s the problem?

If you installed Xcode and/or the Command Line Tools, it ships with its own gcc.
~$ xcode-select -p
/Library/Developer/CommandLineTools

~$ /Library/Developer/CommandLineTools/usr/bin/gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.26.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

That's the same output as
~$ which gcc
/usr/bin/gcc

~$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.26.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

As with most Homebrew installations, Homebrew's gcc is in the Cellar:
~$ ls /usr/local/Cellar/gcc/10.2.0_1/bin | grep gcc
gcc-10
gcc-ar-10
gcc-nm-10
gcc-ranlib-10
x86_64-apple-darwin19-gcc-10
x86_64-apple-darwin19-gcc-10.2.0
x86_64-apple-darwin19-gcc-ar-10
x86_64-apple-darwin19-gcc-nm-10
x86_64-apple-darwin19-gcc-ranlib-10

~$ /usr/local/Cellar/gcc/10.2.0_1/bin/gcc-10 --version
gcc-10 (Homebrew GCC 10.2.0_1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.