Git Not Allowing to push changes to remote Repo - github

I have been facing the following error everytime I try to push changes to a remote repository:
"ERROR: Write access to repository not granted.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. "
I have the SSH keys already set I am able also to git pull and git clone with no problems, the issue is just when I try to push changes.
Do you have any idea about ow to solve it ??
I am using a MacOs .
Thank you in advance for your time.
I removed the SSH keys from github account also I generated them again on my machine and added them again in my github account, but no luck so far.

Related

cannot connect to github, not able to clone or push repo

It was working fine until tomorrow.
But today I am not able to push changes to the repo.
I tried to clone my repo, it also shows the same error.
fatal: unable to access 'https://github.com/nkp1111/python-projects.git/': Failed to connect to github.com port 443 after 21101 ms: Timed out
The same error is showing up. I haven't changed any setting to my knowledge.
It started to clone and stop after one time.
I suspect it is because of antivirus.
What can i do to make it work again?
There can be many causes for the problem, and we will not be able to solve your problem other than suggesting what to do.
have you set any security with temporary credentials? otherwise, it is most possibly also temporary.
try to clone some other repositories, any repository, to test the connection. if you fail to do that, then rest assured it is a temporary GitHub issue.
then try to clone your repo again. if you can clone but can't push back, then you will need to dig into security settings, first on GitHub, then on your computer.
PS: I can clone your repo right now, so I can say GitHub is working toward my country right now.

gitlab push is asking for github credentials?

I'm trying to push some files to a Gitlab project which I've already created in the GitLab GUI. So I'm trying to add some files to that project which already exists.
When I try:
git remote add origin https://git.doit.wisc.edu/my_user_name/my-website.git
I get this error:
error: remote origin already exists.
So I figured I could move on to the next step in the documentation - git branch.
Then I use:
git branch -M main
I was prompted with:
I entered my keychain password and all seemed fine but when I try to do:
git push -uf origin main
The terminal reads:
Username for 'https://github.com':
I put in my username and then get this error:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
It seems like git is confusing gitlab and github. I'm trying to push to gitlab, not github. I'm so confused here. Is there something I'm missing in the first step?
No, Git's not confused here. When you said, git remote add origin… and Git reported an error, that means that the remote origin already exists for that repository. In this case, that remote points somewhere on GitHub, which you can see with git remote -v.
If you want to replace the existing URL for the origin remote, use git remote set-url origin https://git.doit.wisc.edu/my_user_name/my-website.git. If you want to create a new, differently named remote, then do git remote add gitlab https://git.doit.wisc.edu/my_user_name/my-website.git and push with git push gitlab main.
Note also that GitHub no longer allows you to use your account password to authenticate with Git. Instead, when prompted for a password, go to https://github.com/settings/tokens and create a token with the repo scope, and use that instead. However, in this case, since you're intending to push to GitLab, that shouldn't matter here.

Could not read from remote github repository

I am trying to push to a github repo but getting an error
ERROR: Permission to microsoft/playwright.git denied to my_user.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Steps I performed:
1- Successfully Cloned the repo using ssh git#github.com:microsoft/playwright.git
2- But when I am trying to push a branch to it I am received an authentication error
3- Prior to cloning I created a new SSH key and added it [as per instructions here ]
4- I also tested my ssh connection using ssh -T git#github.com and it shows success
Warning: Permanently added the RSA host key for IP address '192.xx.xxx.xxx' to the list of known hosts.
Hi user! You've successfully authenticated, but GitHub does not provide shell access.
5- I also re-cloned the repo after restarting my computer but I still am not able to push to the playwright repo
Regarding to the Fork a repo which describes as the following: -
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.
To collaborate with the public repo, basically we will do the following steps: -
Fork the repo to our own. (in this case, we fork the microsoft/playwright)
Within the forked repo
Make a change/improvement.
Push to the forked repo branch.
If it looks good, then create a pull request back to the upstream to notify them to review and approve.
Sidebar
We may visit the following GitHub documents as a guidance.
Fork a repo
Creating and deleting branches within your repository
About pull requests
Creating a pull request from a fork

Can't find git repository on an enterprise github with token access?

I just started at a new company. This company has an enterprise github site at github.COMPANY.com. I'm on a Windows 10 box, logged into CentOS 7 server through putty, trying to start up a new branch of an existing repository.
They use token access to github (I have no prior experience), and I was able to setup my token, clone the necessary repository, make a test document, and commit it. But when I try to push back to the repo:
$ git push
remote: Repository not found.
fatal: repository 'https://x-access-token:TOKENNUMBER#github.COMPANY.com/innovation/REPO_NAME.git/' not found
The address in quotes is the same exact text as I used to clone the repository
$ git clone htpps://x-access-token:TOKENNUMBER#github.COMPANY.com/innovation/REPO_NAME.git/
So I know the address is valid since I successfully cloned. It appears that I can pull just fine, although there is nothing to pull right now.
$ git pull
Already up-to-date.
Anyone have any ideas about the error message? I was actually thinking that my user might not have permissions to push, which is causing the 'not found' error since my token is not recognized as valid.

How can collaborators push their changes to my repo in GitHub

First I have created one project in Eclipse and committed to my GitHub using below commands:git init
git add .
git commit -m "first commit"
git remote add origin URI of my repo
git push -u origin master
Then I modified one file in Eclipse and committed to GitHub from Eclipse through creating remote and giving the remote URI of the repo.
I added my team member through add collaborator.
Then he downloaded my project and made a change in a file in Eclipse.
Now, how can he push that modified file to my GitHub repository from within Eclipse?
We have done one thing. He created a remote and gave the URI of my repo. But still we are unable to commit that file.
You need to add your colleague as a collaborator. This can be done in the desired GitHub repo via Settings > Collaborators (you need to type in your password again). Afterwards they have those permissions.
UPDATE
Sorry and good morning ;)
I overlooked that you already added your partner as a collaborator. Another possible reason for your situation could be in the Temporary interaction limits where you can, amongst others, limit the interaction with your repo to prior contributors.
If that doesn't help. Please add some more informations about your colleague's git logs.
UPDATE 2
#Rahul K regarding your comment (which you better add to your question, for faster recognition), your colleague first needs to integrate the remote changes via git pull origin master in order to be able to push his or her changes afterwards. But be aware that he or she might need to migrate any conflicts to files both of you applied changes to.
Best regards, David
I have resolved the issue by cloning the repo in my local folder, adding the project to eclipse and changing the file committed.
Before that you have to add that person as a collaborator. So that he/she can clone your repo using the command below:
git clone "Path to the repository"
This is an old question but I'll like to say this to help others that might still be facing this same issue.
I also faced this issue with a friend. I already made him a collaborator but he couldn't push. What we did to solve it was to clone the repo using the ssh url instead. Then we set up authentication in git with ssh. And we were able push successfully.
If you already cloned the repo with the usual HTTPS url, you can change the remote origin url using the git remote set-url origin <url> command but url here will be the ssh url.