Reputation: 175
I have git bash installed on Visual Studio Code Windows. This is what I have so far:
git push
fatal: No configured push destination.
Then I set remote origin to https not ssh because I have a Large file and LFS doesn't work well with SSH (well at least that's what it said in stackoverflow somewhere, I forget)
$ git init
Reinitialized existing Git repository in C:/xampp7.2/htdocs/folder2-temp/.git/
$ git branch -M main
$ git remote add origin https://github.com/mygithubid/myrepository.git
$ git add .
$ git commit
On branch main
nothing to commit, working tree clean
$ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
$ git push --set-upstream origin main
Enter passphrase for key '/c/Users/guestaccount/.ssh/id_rsa':
Uploading LFS objects: 0% (0/1), 0 B | 0 B/s, done.
batch request: [email protected]: Permission denied (publickey).: exit status 255
error: failed to push some refs to 'ssh://github.com/mygithubid/myrepository.git'
So as suggested on stackoverflow I tried this:
$ git remote -v
origin ssh://[email protected]/mygithubid/myrepository.git (fetch)
origin ssh://[email protected]/mygithubid/myrepository.git(push)
Ok Cool. Need to reset that to https://
$ git remote set-url origin https://github.com/mygithubid/myrepository.git
Ok let's see if SSH was reset to HTTPS
$ git remote -v
origin ssh://[email protected]/mygithubid/myrepository.git (fetch)
origin ssh://[email protected]/mygithubid/myrepository.git (push)
Bite me!
Ok someone please help me reset github to https from SSH I am sincerely stuck :D
Upvotes: 0
Views: 472
Reputation: 1009
When you open the C:/xampp7.2/htdocs/folder2-temp/.git/
folder, you should see a bunch of files in this folder, and the file of interest in this case is the config
file.
When you open the config
file, what do you see? There should be something like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]/mygithubid/myrepository.git
fetch = +refs/heads/*:refs/remotes/origin/*
You might not have the same settings under the [core]
section, but the [remote "origin"]
section should be similar. If you want to change the git repo to use https
instead of ssh
, try changing
url = [email protected]:mygithubid/myrepository.git
to
url = https://github.com/mygithubid/myrepository.git
in this config
file directly. This should fix the problem you have, so when you run git remote -v
, you should now see
$ git remote -v
origin https://github.com/mygithubid/myrepository.git (fetch)
origin https://github.com/mygithubid/myrepository.git (push)
EDIT: As discussed in the comments section, modifying files within your .git
directory is generally not best practice since changing something that you're not supposed to change in the .git
directory might corrupt your git workflow for this repo. However, the problem is this case seems to be that the git commands aren't modifying the .git/config
file as they should be, so modifying the url =
line under the [remote "origin"]
would be a workaround to get git
to communicate with the remote server.
NOTE that the changes I suggested above in my original answer will not corrupt your local git repo, but just keep in mind that changing/deleting any of the other folders or files inside the .git
directory might corrupt it if you do make a bad change.
This workaround I suggested will probably get your local repo communicating with your remote repo, but you should probably take a look at your git bash
installation for Windows and check the options you selected since it looks like some of your git commands aren't working as they should be. If the problem isn't with git bash
, it might be some other settings the installer configured for git when you were installing git - unfortunately, debugging this is tricky without a comprehensive understanding of the git configuration, so you might need to do some digging on your own here :)
Upvotes: 1