如何配置git以避免意外的git推送 [英] How to configure git to avoid accidental git push

查看:93
本文介绍了如何配置git以避免意外的git推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  remote.origin.url =< some url> 

在git clone之后,新回购库中的配置文件如下所示: ;
remote.origin.fetch = + refs / heads / *:refs / remotes / origin / *
branch.master.remote = origin
branch.master.merge = refs / heads / master

然后,我可以执行git pull和git push。但我只对git pull感兴趣,因为我想推入另一个回购。



我可以做的一件事是:

  git add remote repo-for-push< some other url> 
git push repo-for-push master

但是我想配置git来使用默认和独特的存储库的拉和推,即:

  git pull#从原点拉#$ b $ git push#push into repo-for-push,避免意外推入原产地

这怎么配置?
提前致谢


编辑:

基本上,我想设置默认的推送回购不同于默认的读取/拉回购。

解决方案

看起来像

  git config remote.origin.receivepack / bin / false 


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.

解决方案

Looks like

git config remote.origin.receivepack /bin/false

Makes push to remote origin fail.

这篇关于如何配置git以避免意外的git推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆