{"id":958,"date":"2022-02-18T21:30:05","date_gmt":"2022-02-18T16:00:05","guid":{"rendered":"https:\/\/mutesoft.com\/spaces\/software\/?p=958"},"modified":"2023-01-03T18:55:50","modified_gmt":"2023-01-03T13:25:50","slug":"update-cached-credentials-in-git-repository","status":"publish","type":"post","link":"https:\/\/mutesoft.com\/spaces\/software\/update-cached-credentials-in-git-repository.html","title":{"rendered":"Update Cached Credentials in Git Repository"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/mutesoft.com\/spaces\/software\/wp-content\/uploads\/sites\/7\/2022\/02\/git-e1672746066670.png\" alt=\"Git repository\"\/><figcaption class=\"wp-element-caption\">Git<\/figcaption><\/figure>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mutesoft.com\/spaces\/software\/update-cached-credentials-in-git-repository.html\/#Context\" >Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mutesoft.com\/spaces\/software\/update-cached-credentials-in-git-repository.html\/#Remove_Cached_Credentials_from_Git_Repository\" >Remove Cached Credentials from Git Repository<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mutesoft.com\/spaces\/software\/update-cached-credentials-in-git-repository.html\/#Update_Cached_Credentials_in_Git_Repository\" >Update Cached Credentials in Git Repository<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"context\"><span class=\"ez-toc-section\" id=\"Context\"><\/span>Context<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you have cached your git credentials for a repository or globally, a couple of scenarios might arise:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Cached credentials need to be updated for a single repository, or globally<\/li>\n\n\n\n<li>Cached credentials need to be removed for a single repository, or globally <\/li>\n<\/ol>\n\n\n\n<p>Refer to this article on <a href=\"https:\/\/mutesoft.com\/spaces\/software\/avoid-entering-git-credentials-every-time.html\" target=\"_blank\" rel=\"noreferrer noopener\">how to cache git credentials<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"remove-cached-credentials-from-git-repository\"><span class=\"ez-toc-section\" id=\"Remove_Cached_Credentials_from_Git_Repository\"><\/span>Remove Cached Credentials from Git Repository<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to remove cached credentials from a specific repository in a terminal, change the directory to the root folder of the repository, and open <code>.git\/config<\/code> file. In the <code>config<\/code> file add a <code>credentials<\/code> block as shown below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Change directory to the root directory of the repository\ncd &lt;repo-dir>\n\n# Open config file from the root directory of the repository\nvi .git\/config\n\n# Add following lines to config file\n[credential]\n        helper =\n\n# In case you want to apply it globally add the above \n# configuration to ~\/.gitconfig file\nvi ~\/.gitconfig<\/pre>\n\n\n\n<p>Alternatively, add the above configuration using <code>git<\/code> command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Execute the following from a git repo directory, applicable to that repo only\ngit config credential.helper \"\"\n\n# Execute the following from a git repo directory, for global configuration\ngit config --global credential.helper \"\"<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"update-cached-credentials-in-git-repository\"><span class=\"ez-toc-section\" id=\"Update_Cached_Credentials_in_Git_Repository\"><\/span>Update Cached Credentials in Git Repository<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In order to update cached credentials first, remove cached credentials following the steps mentioned above. After removal, <code>Git<\/code> will start asking for credentials in subsequent operations. Then, change the credential cache configuration to ensure credentials are cached. Refer to this article on <a rel=\"noreferrer noopener\" href=\"https:\/\/mutesoft.com\/spaces\/software\/avoid-entering-git-credentials-every-time.html\" target=\"_blank\">how to cache git credentials<\/a>. Here are the steps:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Execute the following from a git repo directory, applicable to that repo only\ngit config credential.helper store\n\n# Execute the following from a git repo directory, for global configuration\ngit config --global credential.helper store<\/pre>\n\n\n\n<p>Alternatively, open the <code>.git\/config<\/code> file in a text editor and add <code>credential<\/code> block as shown below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Change directory to the root directory of the repository\ncd &lt;repo-dir>\n\n# Open config file from the root directory of the repository\nvi .git\/config\n\n# Add following lines to config file\n[credential]\n        helper = store\n\n# In case you want to apply it globally add the above \n# configuration to ~\/.gitconfig file\nvi ~\/.gitconfig<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you have cached your git credentials for a repository or globally, a couple of scenarios might arise: 1. Cached credentials need to be updated for a single repository or globally 2. Cached credentials need to be removed for a single repository or globally.<\/p>\n","protected":false},"author":2,"featured_media":1053,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"If you have cached your git credentials for a repository or globally, a couple of scenarios might arise: 1. Cached credentials need to be updated for a single repository, or globally 2. Cached credentials need to be removed for a single repository, or globally.","_seopress_robots_index":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[32],"tags":[31],"class_list":["post-958","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools","tag-git"],"_links":{"self":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/comments?post=958"}],"version-history":[{"count":10,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/958\/revisions"}],"predecessor-version":[{"id":1371,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/958\/revisions\/1371"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media\/1053"}],"wp:attachment":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media?parent=958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/categories?post=958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/tags?post=958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}