1

I'm pretty new to git, but even from all the searching I've done, this still seems like a really abnormal situation.

I'm working on a school project with three other people, and we're all working off the same repo owned by A. B and C have no issue pushing to the repo and have never had to enter credentials, but every time I try to push, git (using git bash if that matters) gives an error (fatal: NullReferenceException encountered. Object reference not set to an instance of an object.) and then asks for "http://github.com/" username and password. I have tried it with both my credentials and A's credentials, but it always says I am unauthorized (even when trying to push in Eclipse).

According to git remote show origin I am properly attached to the right repo, and pulling wont help (which seems to work ok) because with all my troubleshooting/testing, my local master is 8 commits ahead of the remote master.

I'm trying to give as much detail as possible, but I'm still not super familiar with git, so I'm probably leaving something out. I'll probably be watching this thread fairly closely though.

3 Answers 3

1

You must check that your origin is a proper GitHub URL

https://github.com/aUser/aProject

or:

[email protected]/aUser/aProject

Then make sure you are a collaborator on (or the owner of) that project.

Check in your bash session your .profile or .bashrc or .bash_profile: its content could also trigger an error.

12
  • I know it's origin's GitHub URL is correct, and I know I'm a collaborator on that project. A sent me an invite and I accepted it. This is git bash for Windows, so is there even a .profile or .bashrc or .bash_profile?
    – PaulBunion
    Oct 17, 2018 at 5:30
  • @TheRandomSpectator can you try, just for testing, a git push -u https://yourGitHubLogin@YourGitHubPassword:github.com/aUser/aRepo.git master?
    – VonC
    Oct 17, 2018 at 5:36
  • Still gave a fatal error, but this time it was different. fatal: unable to access 'http://myGHLogin@myGHPassword:github.com/aUser/aRepo.git/': Port number ended with 'g'
    – PaulBunion
    Oct 17, 2018 at 6:24
  • @TheRandomSpectator Sorry try login:password@github, not login@password:github
    – VonC
    Oct 17, 2018 at 6:54
  • 1
    @The then you need to percent encode it: stackoverflow.com/a/35195690/6309
    – VonC
    Oct 17, 2018 at 16:30
1

In the end, the issue was that I am using 2FA on github, so I couldn't just directly sign in with my password. I had to first create a personal access token which you can read about here.

Next I stored this by disconnecting the origin, then re-adding it using the https URL, and using the personal access token as the password, and this permanently stored the credentials.

git remote remove origin
git remote add origin https://myUsername:[email protected]/aUsername/aRepo.git
git push --set-upstream origin master
1
  • 1
    Well spotted (for my other answer) :) +1
    – VonC
    Oct 18, 2018 at 17:23
-1

Are you working in Visual Studio? If so In VS, go to the View menu > Other Windows > Command Run “Tfs.tfc trace /start /logfile:C:\sometempdir\log.txt /keywords:TFS.All=4” to capture the logs

2
  • This is a comment, not an answer.
    – castis
    Oct 17, 2018 at 0:46
  • No. I said I'm working in git bash for all the actual git stuff, but my IDE is Eclipse. Yes, I know I could be doing git in Eclipse, but I said I'm having the same issue in Eclipse.
    – PaulBunion
    Oct 17, 2018 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.