I'm having difficulty pushing changes from Visual studio code to Github. For context, I’m relatively new to git and github — after looking through past SO discussions and other online forums, and tried the following: using git init/git remote origin to connect local computer with github, as well as generating an SSH key.
However, None of these things seem to work. When I type in
git push -u origin master
the terminal responds with error: src refspec master does not match any
.
Additionally, I’m not sure if this is of relevance, but when I type in
~/.ssh/config
the terminal responds with the term '~/.ssh/config' is not recognized as the name of a cmdlet, function, script file, or operable program.
Any ideas on troubleshooting would be appreciated. Thanks everyone!
CodePudding user response:
error: src refspec master does not match any
indicates the local repository does not have a branch named master. It could be main
or another name. Run git branch
to list local branches. And the current checked-out one has an *
before the name.
As to the 2nd error, when you type in ~/.ssh/config
, it tries to execute this file. But the file is not executable (and it should not be), and it's not a cmdlet, function, script file, or operable program.
The 1st error has nothing to do with ~/.ssh/config
.
CodePudding user response:
When I ran "
git push origin main
", the terminal gave messh: connect to host github.com port 22: Connection timed out fatal: Could not read from remote repository.
It depends on your context, but in my corporate environment, SSH is closed for outgoing queries.
Meaning I have to use an HTTPS URL (after creating a Personal Access Token, to use as password)
cd /path/to/local/repository
# if you had already defined "origin"
git remote set-url origin https://github.com/me/MyNewRepo
Don't forget to create an empty 'myNewRepo' repository on GitHub first.
You can do so directly from your workstation.
Install GitHub CLI gh
, and:
cd /path/to/local/repository
gh repo create myNewRepo --source=.