Search code examples
gitvisual-studiogithubsshversion-control

git multiple accounts and repository problems


I want to use git with Visual Studio project. I already had a personal account which worked fine. Now my employer gave me a new account and visual studio is still trying to push to my personal account and gives me error on publish and syncs.

So i followed this tutorial:https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574

  • created new ssh key
  • created an identity to it
  • added that ssh key to my github account
  • added identity to ssh config

Now some of the things i am unclear about

i have created 2 origins + the default one which are origin (default) myorigin (not used) georigin (path:git@github-ge:ge/geweb)

when i type $ git config --global -l it gives me my correct(employer's) user.name and user.email

geweb is the name of my new repository the url of my repository is:https://github.com/ge/geweb.git

when i try pushing to georigin it says repository not found when i try pushing to origin it says error: src refspec master does not match any.

also, no where have i mentioned my second git account's username and password

also, i have 2 emails in my git account user.email in config is not the primary one. could that be the reason?

i am quiet confused at how it works end-to-end.

After failing to push i tried to unbind the project from source and deleted .git files from my project folder but team explorer is still showing unsynced commits and changes

the output of git remote -v is:

  • myorigin git@github-ge:ge:getWeb.git (fetch)
  • myorigin git@github-ge:ge:geWeb.git (push)

Solution

  • So, it turned out that i had multiple problems with setting up my account.

    1. it was picking the wrong origin which was identified by Shaun and Marina

    So, i removed the wrong one and added the correct one (georign)

    1. I had added a readme file to the default repository it was giving me error: hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    so i tried a pull before pushing and it turned out i had to --allow-unrelated-histories

    git pull georigin master --allow-unrelated-histories
    

    and then

    git push georigin master
    

    Thats it!!! (phew)