After git clone, the config in the new repo looks like:
remote.origin.url=<some url> remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master
Then, I can execute "git pull" and "git push". But I'm interested in only do "git pull", because I want to push into another repo.
One thing I can do is:
git add remote repo-for-push <some other url> git push repo-for-push master
But I would like to configure git to use default and distinct repositories for pull and push, i.e:
git pull # pulls from origin git push # pushes into repo-for-push, avoiding accidental push into the origin
How can this be configured? Thanks in advance.
EDIT:
Basically, I want to setup the default push repo to be different from the default fetch/pull repo.
If you have the appropriate permissions on your "central" git repository, you can disable force push by git config --system receive. denyNonFastForwards true .
To find it go to Settings > Branches > Branch Protection Rules and click 'Add Rule'. Then, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging. By default, this only stops people who are not moderators.
It's important to fetch and pull before you push. Fetching checks if there are any remote commits that you should incorporate into your local changes. If you see any, pull first to prevent any upstream merge conflicts.
Looks like
git config remote.origin.receivepack /bin/false
Makes push to remote origin fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With