Although you can workaround with:
git remote remove origin
git remote add origin https://[personal-access-token]@github.com/username/repo_name.git
Cloud Shell is just a Debian-based Linux distribution which includes Git pre-installed.
As it is told in this issue tracker report, we don't do anything special with git credentials in Cloud Shell. As long as the credentials are in the user's home directory, they will be persisted across sessions. Otherwise, Cloud Shell works the same as any other Linux VM, so it's possible the user messed up their global or repo git configuration somewhere.
As you can read here, the git credentials can be stored in ~/.git-credentials
but also in another file like ~/.my-credentials
. The “store” mode saves the credentials to a plain-text file on disk, and they never expire. This means that until you change your password for the Git host, you won’t ever have to type in your credentials again. The downside of this approach is that your passwords are stored in cleartext in a plain file in your home directory.
You can also find your credentials as described here in .git/config
file. In Cloud Shell, you can find it in ./cloudshell_open/python-storage/.git
from your $HOME
directory. config
is the local configuration file, as you can read in this post.
As established here, the Git configuration file contains a number of variables that affect the Git commands' behavior. The .git/config
file in each repository is used to store the configuration for that repository, and $HOME/.gitconfig
is used to store a per-user configuration as fallback values for the .git/config
file. The file /etc/gitconfig
can be used to store a system-wide default configuration.
With this respect, there’s no particular configuration related to Cloud Shell.
In other case, when authenticating with git, if you're working with Cloud Source Repositories, Cloud Shell handles authentication for you automatically. If that’s your case, you could view your repository settings and display your repository location. This could be outdated with the previous one before you move it to the new organization.
Probably you also need to toggle between your repositories to connect to the one that is in your new organization. This updates your Source Control: Git panel with the context of your chosen repository.