4

I want to switch to remote branch, but before that i do a fetch, so that branch get available to switch. But I want this to be done providing username/password with command itself like git pull "https://<un>:<pwd>"git.com/<repo>" <branch> pull works fine with username password but how can i used the same way for fetch command

Rajkumar Natarajan
  • 6,821
  • 15
  • 62
  • 127

1 Answers1

-3

git pull does a git fetch anyway (followed by a merge)

So if your command worked with git pull, the same URL should work identically with git fetch.

That being said, it is a better practice to cache those credentials in a credential helper.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • *So if your command worked with git pull, the same URL should work identically with git fetch* Yes it should, but it doesn't. Using fetch with the repository argument does update nothing as far as I can tell while git pull with the repository argument will update the local branch but not the remote branch. – Roman Reiner Mar 22 '19 at 13:36
  • @RomanReiner OK. Can you post a new question with more details illustrating your issue? That help me (and others) for proposing a solution. – VonC Mar 22 '19 at 18:37
  • git pull does things which are conceptually different than git fetch – user3480922 Jul 05 '19 at 07:02
  • @user3480922 I agree: git pull does not indeed always do a git fetch: https://stackoverflow.com/a/18924297/6309 – VonC Jul 05 '19 at 07:31