6

I have a Basic git clone command to bitbucket in which I have to add Login credentials, is it possible to add Login credentials to a bitbucket git clone command?

https://myacc@bitbucket.org/myacc/app.git

Something like this?

https://myacc@bitbucket.org/myacc/app.git -Password "123"
Jon not doe xx
  • 533
  • 3
  • 10
  • 20
  • Possible duplicate of [Is there a way to skip password typing when using https:// on GitHub?](https://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-typing-when-using-https-on-github) – phd Oct 18 '18 at 13:10
  • https://stackoverflow.com/search?q=%5Bgit%5D+credentials+in+URL – phd Oct 18 '18 at 13:11

1 Answers1

13

You can, with:

git clone https://user:password@bitbucket.org/myacc/app.git

But this will save your credentials in the origin url in .git/config.
To avoid that you could change the origin afterwards
git remote set-url origin https://myacc@bitbucket.org/myacc/app.git

ColdIV
  • 1,118
  • 2
  • 13
  • 21
  • Do I Need to add the Project Name if in the git remove command if I start like this?`git clone https://user:password@bitbucket.org/myacc/app.git MyApp` so should it be this? `git remote set-url origin https://myacc@bitbucket.org/myacc/app.git MyApp` – Jon not doe xx Oct 18 '18 at 08:31
  • It should work the way I posted it. The project should already be included in the URL. – ColdIV Oct 18 '18 at 08:37
  • Ok thanks it seems to work, can you explain me this further I do not understand why this is an issue `But this will save your credentials in the origin url in .git/config.` – Jon not doe xx Oct 18 '18 at 08:44
  • It does not have to be an isse.
    In your projects local `.git` folder is a config file, and whoever has access to this file will then have your credentials, as it stores the origin url in it. But if you are the only one on your PC with access to this file, then there is no issue.
    – ColdIV Oct 18 '18 at 08:46
  • 1
    What if password contains a `@` ? – Marinos An Dec 18 '19 at 15:03
  • 3
    @MarinosAn You can type %40 for @. More info: https://fabianlee.org/2016/09/07/git-calling-git-clone-using-password-with-special-character/ – Genki Mar 14 '20 at 03:05