Github: how to restrict commits on a public repository - github

Is there a way to restrict users from making commits to a public repository? I may understand incorrectly, but private repos are not free, and also for private, users cannot access the repo unless invited as a collaborator. I would like GH users to still access the repo, but not able to push commits to it.
Thanks.
EDIT:
Thanks I looked at the link. It it still not clear to me because I used the clone url on the repo page and was able to clone and push to the master branch on the repo without even setting config user.name and user.email, which in my opinion seems like anyone else can do this as well.

I didn't notice a difference in read only git:// in the clone url as opposed to the read and write access way with git#. When I tried to push to another's repo using https (which has both read and write access), I got a 403 error (authentication error). The message included my GH username, which made me curious as to how GH knew that. Turns out they have a copy of the computer key that is initiating a push. So finally, only owners and collaborators can push to a repo. I was able to push to my own repo with the https because of my key.
git github cannot push to origin
How does GitHub handle push security?

You can try the Branch protection rule. it will restrict commits up to an extent. It is under Settings --> Branch

Related

Some confusion about the traffic of github repo?

As the pictures show below, the git clones of my repo is 26, and the visitor of my repo is 4. According to the literal meaning, the cloners means who look my repo page and decide to clone my repo to local or somewhere, and also, in the meantime, they should become the visitors of my repo. However, the traffic data of my repo shows that the results of visitors and cloners are much different from each other.
My insight of visitor and coloner is right? What is the GitHub official definition of the cloners and visitors? Or, the significant difference that shows on my picture just caused by the bug of GitHub.
The command git clone http://url will clone the repo without visiting GitHub. Maybe your repo's name is an easy misspelling of another repo, or someone attempted to download all repos by cloning from a list of URLs, looking for loose passwords or doing statistical research.
It could be cloned by you from another IP (other home/TOR/VPN) or you told someone about the repo and someone cloned it without visiting the page.
Do you have a CI/CD server or a DevOps pipeline?
These will clone your repo automatically when triggered by a commit or
a pull request.

Pushing files from one account to other in github

Iam trying to push some changes to other account from another account but it is giving me permission error.I checked the github settings but everything there seems to be right.Can anybody help me with this?
EDIT:
I tried changing my user name and email too still it is giving same error
Some info about the transfer process which might help you
When a repository is transferred between two user accounts, issue assignments are left intact. When you transfer a repository from a user account to an organization, issues assigned to members in the organization remain intact, and all other issue assignees are cleared. Only owners in the organization are allowed to create new issue assignments. When you transfer a repository from an organization to a user account, only issues assigned to the repository's owner are kept, and all other issue assignees are removed.
If the transferred repository contains a GitHub Pages site, then links to the Git repository on the Web and through Git activity are redirected. However, we don't redirect GitHub Pages associated with the repository.
All links to the previous repository location are automatically redirected to the new location. When you use git clone, git fetch, or git push on a transferred repository, these commands will redirect to the new repository location or URL. However, to avoid confusion, I strongly recommend updating any existing local clones to point to the new repository URL. You can do this by using git remote on the command line:
$ git remote set-url origin new_url
Add the collaborator from the initial account (the git account having the repo) and the second account can accept the invitation to be a collaborator
This allows you to change and push the code from different Id also.

Push Error GitKraken

Can't push may changes to the repo with GitKraken.
I have the credentials CORRECT. Since is a private repo, I had to clone the repo via URL. I did that with my user (authorized of course). I DID commits before, and now I just cant push again.
I'm the only one working on this breanch.
Any thoughts?
It was a permission problem. Turn's out I had no permission to writte.

Unable to git push julialang

I'm trying to get the latest julia master commit.
I instaled it via git clone, however, when I do
$ git push
It returns an exception:
fatal: remote error: You can't push to git://github.com/JuliaLang/julia.git
Use https://github.com/JuliaLang/julia.git
If I use the option given, git requires me a password.
It sounds like you probably don't actually want to push to the JuliaLang repository, but rather pull from it.
You git pull to fetch upstream changes and integrate them into your local repository. So, for example, to update and rebuild Julia, you would git pull && make clean && make from within julia's directory while on the master branch.
You would only git push if you were a contributor submitting changes. But even among contributors who have commit access, very few actually push directly to the master branch. Most create branches, submit those, and then open a pull request for a review. And for that workflow, you don't even need to be a contributor. You can "fork" the project on Github, and then push to your forked repository online. From there, you can open a pull request for review.
git:// doesn't allow for authentication.
ssh or https does.
In the case of https, it is asking for your GitHub username and password.
See more at "Git - the Protocols".
GitHub needs to know who you are, because only the owner (or a collaborator) has the right to push (while everybody can clone/pull from a public repo, which is why git:// works for cloning).
See "Permission levels for a user account repository".
Note: here github.com/JuliaLang is an organization, which means only the owner and members/teams can push to a repo declared in that organization.
Se more at "Permission levels for an organization repository".

How to take update from github repository?

I have installed GitHub Client to my system.
I have easy to commit my changes to the repository. But my colleague tried to take my update, he is not able to took the app from repository.
We are having GitHub private repository.
Kindly let me know to solve this issue.
The similar question has been asked before follow this link hope it may help you.
Basic flow is like this.
# clone the repository (from github, for example)
git clone git#github.com:username/reponame.git
cd reponame
# edit some files
# add them to the index
git add file1.txt
git add file2.gif
# review your changes
git status
# commit the changes
git commit -m "Decription of my change"
# push them back to the remote repository
git push origin master
If your colleague is supposed to:
access your private repo
be able to contribute back (git push) directly to that private repo
you should add him/her to the list of collaborators for this project: see "GitHub help page".
Note that Users can always collaborate on private repositories, even on the free plan.
I.e. if a user has a GitHub account (even a free one), he/she can be added to a private repository.