{"thread":{"id":"41270","subject":"Need support with git credential storage","startedAt":"2016-01-27T21:49:38Z","lastAt":"2016-01-27T22:28:34Z","messageCount":2,"participants":["Charles Bélanger","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"276936","messageId":"CY1PR0701MB1836FFF6CEAC69DFB5E86DACB7D90@CY1PR0701MB1836.namprd07.prod.outlook.com","threadId":"41270","inReplyTo":null,"subject":"Need support with git credential storage","fromName":"Charles Bélanger","fromEmail":"cbelanger@addenergie.ca","sentAt":"2016-01-27T21:49:38Z","receivedAt":"2016-01-27T21:49:38Z","isPatch":false,"sender":{"key":"cbelanger@addenergie.ca","avatar":null},"body":"Hello Git Community,\n\nI'm working at AddEnergie at Quebec city in Canada and I'm currently working on making a Build Server in a Virtual Machine running Ubuntu.\nWe are using git for our source code and I'm the first one here that need to use git store credentials for an Automated Build Server that would run overnight.\n\nI'm wondering if you could provide me support about it because I'm having issue making it works.\nThe clue I have right now about my git store credential issue is when I'm doing a git clone of my project repo, I'm having following errors:\n\nHere's the git clone command launch by a .sh script file called from ~/.profile:\ngit clone https://MyUserName@bitbucket.org/CompanyName/ProjectName.git ~/Projects/SubFolderName/ProjectName\n\nHere's the error from bash .profile:\nFatal: unable to access 'https://MyUserName@bitbucket.org/CompanyName/ProjectName.git/':\nCould not resolve host: bitbucket.org\n\nI followed the excellent Web page here:\nhttps://git-scm.com/book/be/v2/Git-Tools-Credential-Storage\n\nHere's what I use as commands:\ngit credential-store --file ~/git.store store\nprotocol=https\nhost=bitbucket.org/CompanyName/ProjectName.git\nusername=MyUserName\npassword=MyPassword\n(type enter on a blank line to exit)\n\ngit credential-store --file ~/git.store get\nprotocol=https\nhost=bitbucket.org/CompanyName/ProjectName.git\n(type enter on a blank line to exit)\n\n\nHere's what the ~/git.store file looks like:\n        https://MyUserName:MyPassword@bitbucket.org%2fCompanyName%2fProjectName.git\n\nI tried changing the %2f by / inside the git.store file and also tried // but it's still showing the same fatal error.\nPerhaps I don't use the host=  property correctly.\n\nMay I ask you helping me with this ?\n\nBest Regards,\n\nCharles Belanger\n"},{"id":"276941","messageId":"20160127222834.GA355@sigill.intra.peff.net","threadId":"41270","inReplyTo":"CY1PR0701MB1836FFF6CEAC69DFB5E86DACB7D90@CY1PR0701MB1836.namprd07.prod.outlook.com","subject":"Re: Need support with git credential storage","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-01-27T22:28:34Z","receivedAt":"2016-01-27T22:28:34Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 27, 2016 at 09:49:38PM +0000, Charles Bélanger wrote:\n\n> Here's the git clone command launch by a .sh script file called from ~/.profile:\n> git clone https://MyUserName@bitbucket.org/CompanyName/ProjectName.git ~/Projects/SubFolderName/ProjectName\n> \n> Here's the error from bash .profile:\n> Fatal: unable to access 'https://MyUserName@bitbucket.org/CompanyName/ProjectName.git/':\n> Could not resolve host: bitbucket.org\n\nI don't think this is related to credentials. The credential code should\nnever do a network hostname lookup. It looks more like git-clone is\nfailing to contact the host in the first place.\n\nTry \"ping bitbucket.org\", which would presumably yield the same error.\nIf so, you need to figure out why you cannot resolve the name, but\nthat's beyond the scope of this list.\n\n> I followed the excellent Web page here:\n> https://git-scm.com/book/be/v2/Git-Tools-Credential-Storage\n> \n> Here's what I use as commands:\n> git credential-store --file ~/git.store store\n> protocol=https\n> host=bitbucket.org/CompanyName/ProjectName.git\n> username=MyUserName\n> password=MyPassword\n> (type enter on a blank line to exit)\n\nThis comes from the \"under the hood\" section, I think. In normal use,\nyou shouldn't need to run the credential-helper directly. Just configure\nit, via:\n\n  git config credential.helper \"store --file ~/git.store\"\n\nThe first time git needs a password, it will prompt you on the terminal,\nand then store the result in that file.\n\nIf you do want to pre-seed the store, you can do so using a command like\nthe one above. But as you noted later, the \"host\" field should be _just_\nthe hostname, not the rest of the url path. That would go in the \"path\"\nfield if you want it, but typically git does not even bother to store\npaths, and just keys on whole domains (see \"credential.useHttpPath\" in\n\"git help config\" for more details).\n\nYou can also specify a URL using the special key \"url\", which is then\nparsed into its components. So for example:\n\n  $ git credential-store --file my-store store\n  url=https://bitbucket.org/CompanyName/ProjectName.git\n  username=foo\n  password=bar\n  [blank line to end]\n\n  $ cat my-store\n  https://foo:bar@bitbucket.org/CompanyName/ProjectName.git\n\n  $ git credential-store --file my-store get\n  url=https://bitbucket.org/\n\n  [blank line ends our input, the rest is output]\n  username=foo\n  password=bar\n\n> Here's what the ~/git.store file looks like:\n>         https://MyUserName:MyPassword@bitbucket.org%2fCompanyName%2fProjectName.git\n> \n> I tried changing the %2f by / inside the git.store file and also tried // but it's still showing the same fatal error.\n> Perhaps I don't use the host=  property correctly.\n\nRight. It should be:\n\n  https://MyUserName:MyPassword@bitbucket.org/CompanyName/ProjectName.git\n\nThough as before, you can omit \"CompanyName/ProjectName.git\" completely,\nto cover the whole domain.\n\n-Peff\n"}]}