It is simple to skip typing password when to execute git psuh
command.
vim .netrc
machine github.com
login user1
password pass-user1
How to write .netrc for two accounts for skipping typing password when to git push?
It is no use to write the .netrc as following.
vim .netrc
machine github.com
login user1
password pass-user1
login user2
password pass-user2
Edit .netrc as below according to VonC.
machine github.com login user1 password pass-user1
machine github.com login user2 password pass-user2
Strange errors for git push.
git push -u origin master -f
remote: Permission to user2/test.git denied to user1.
fatal: unable to access 'https://github.com/user2/test/': The requested URL returned error: 403
git remote -v
origin https://github.com/user2/test (fetch)
origin https://github.com/user2/test (push)
The correct syntax would repeat the machine.
And you can write both entries on their separate lines:
machine github.com login user1 password pass-user1
machine github.com login user2 password pass-user2
But then, make sure your origin remote URL specifies one of the two users:
If you already had an origin
remote defined, change it with:
git remote set-url origin https://user2@github.com/user2/arepo.git
But if you are using a new local repo, without any origin
, add it with:
git remote add origin https://user2@github.com/user2/arepo.git