Fatal: master cannot be resolved to branch - github

Here's a screenshot of what I'm dealing with:
I'm a new GitBash user and am getting this error when trying to push to GitHub.
I was following this tutorial. So far I've not run into any problems, except I get this error when I try to push:
Fatal: master cannot be resolved to branch
Things I've done correctly:
I am signed in
I have specified my name and email using git config -global... *blah blah*
Everything is committed and should be ready to push
I'm on the master branch that I wish to push.
I've added my remote repository using command git remote add origin https://github.com/Tawnwen/MyApp.git.
I tried to push using the command git push -u origin master
Can anyone please help?

Related

How to resolve "fatal: unable to access " error

I'm a beginner to GitHub.I need to send a pull request to the master branch.
when i typed the code
git push origin master
It gives me the error
fatal: unable to access
'https://github.com/www-prolificme-com/mahawiki/': The requested URL
returned error: 403
Updated
You mentioned you are trying to pull from git but the command is git push. Anyways, most probably you are getting this error because your repo url is not set locally.
If this is the first time you are sending git request from your system, you might want to setup your username by git config --global user.name "John Doe"
If you have already used git on your system, try checking the git configuration on your system using git config --list command to check whether your repo URL is setup or not.
If the url is not setup run git remote set-url origin https://github.com/www-prolificme-com/mahawiki/
Run git remote -v to verify if your url is setup
git add .
git commit -m "your message"
git push origin master
Remove/Update the saved credentials:
Click Start
Search for 'Credential Manager'
Select 'Windows Credentials Manager' > 'Windows Credentials'
Search for the credentials that you want to remove/update
Click on the credential entry > Click 'Edit' or 'Remove'
your repo is not setting locally
so, you seemed crash message
first
git config --list
to showing your git repo set list
and
git remote set-url origin <your git repo address>
to access git repo and git add . to add your files to git container
git commit -m "your git commit message"
this is your git commit message version or anything possible
git push origin master
finally your files pushing on git repo
it's done!
try it
I got this same problem then I try to this below command.
step 1:
git config --global user.email "user email"
step 2:
git config --global user.name "user name"
After running those commands, you can use this command to push your code:
git push origin master
Even if you set all credentials and other setups in the local machine, you might face this problem.
Currently, GitHub uses 'personal access token' so when or after creating personal access token you must check the Select scopes.
You select all you need and then push again.
It will be pushed successfully.
If nothing working please check if you have checked the below checkboxes while creating token

Push a local file to an existing GitHub remote repo

Trying to push a committed file to an existing remote repository on GitHub.
Below I verified and I'm trying to push to the Django. I've tried git push, and git push -u Django master. Any help would be appreciated. I have been saving all of my files locally and I am now adding all to GitHub and it's a little confusing.
Roberts-MBP:Django robertamato$ git remote -v
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (fetch)
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (push)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (fetch)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (push)
Roberts-MBP:Django robertamato$
Here is a error code it threw, I see it suggests to fetch first but I'm not to familiar with how that process works.
Roberts-MBP:Django robertamato$ git push -u Django master
To https://github.com/CodingDojo-Python-09-04/Robert_Amato.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/CodingDojo-Python-09-04/Robert_Amato.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.

can't able to perform git push, permission denied?

I already made a repository in github as wordpress-template.
I created a .git repository locally, added some files there, and committed it.
Then I created a remote as origin and give it the url of the github repository as:
git remote add origin git#github.com:squalporeover/wordpress-template.git
Now I want to push my master branch to that repository. I ran the following command:
git push origin master
But it shows:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It looks like you added the SSH version of the remote URL. In order to use this you need to set-up Github with SSH.
Otherwise use the HTTPS version of the clone URL which will ask for your username and password:
You need to use ssh-keygen to generate an ssh key pair.
See: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
Duplicate found here: Git - Permission denied (publickey)
This worked for me:
Step 1- git remote rm origin
Step 2-select the http option in github
step 3- run the following command again
git remote add origin https://github.com/yourdirectory/link.git
git branch -M main
git push -u origin main

Adding an existing project through Github using the command line (terminal)

I am having issues with adding an existing project through Github using terminal. I used the following commands:
In Terminal, add the URL for the remote repository where your local repository will be pushed.
# Sets the new remote
git remote add origin remote repository URL
# Verifies the new remote URL
git remote -v
Push the changes in your local repository to GitHub.
# Pushes the changes in your local repository up to the remote repository
# you specified as the origin
git push origin master
It came with the following results:
remote: Permission to Bloc/bloc-jams-student-skeleton.git denied to ynoorstani.
fatal: unable to access 'https://github.com/Bloc/bloc-jams-student-skeleton.git/': The requested URL returned error: 403
Any helpful tips or insight would be awesome!
You could write to this repo (push) only if you were part of the Bloc organization members (here is the list).
Since you are not in that list, you would need to fork that repo in order to push to it.

GitHub pushing/pulling error

I'm kinda new to GitHub, and I just created my account and set it up, etc. I followed the steps very carefully on http://help.github.com/create-a-repo/ but then when I do the very last command ($ git push -u origin master) it says:
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
I have made the Repository, and it matches the name, but I still can't seem to get it to work. Any suggestions?
git will try to contact the remote repo you just declared in the previous line of the GitHub tutorial:
git remote add origin git#github.com:username/Hello-World.git
git push -u origin master
As illustrated in:
"Why are Github project document page urls case sensitive? What are the negative effects?", and
"github http clone returns 'did you run git update-server-info on the server'",
your error message is likely the result of a:
case mistake (git remote add origin git#github.com:username/**h**ello-**w**orld.git)
or url error (git remote add origin git#github.com:username/HelloWorld.git, forgot the '-').
The OP user1302394 confirms, in the comments:
git remote -v gives me:
origin git#github.com:username/Helloworld.git (fetch)
origin git#github.com:username/Helloworld.git (push)
Which means he/she combined a double whammy:
case mistake (world instead of World)
and url mistake (Helloworld insteadd of Hello-World)