是否可以自定义.gitignore?只读访问权限?

如何解决是否可以自定义.gitignore?只读访问权限?

| 我在团队环境中工作,已经有一个“ 0”文件。 我想将更多项目添加到“ 0”文件中,但是我不想在任何一个中检查该文件。可以设置仅适用于我的自定义忽略文件? 另外,我想授予某人对我们服务器上私有git存储库的只读访问权限,如果我将他们的SSH密钥添加到我们的服务器中,他们将像其他所有人一样获得完全访问权限。如何将其限制为只读,不允许提交。     

解决方法

将您的私人忽略规则放在
.git/info/exclude
中。参见
gitignore(5)
。 对于只读访问,请使用
git-daemon
,Web服务器或Gitosis或Gitolite。     ,我知道我的谈话时间有些晚,但是您可能要考虑使用
git update-index --assume-unchanged [ FILE ]
如git帮助文档所述:   当“假定未更改”位打开时,git停止检查工作树文件是否可能进行修改,因此您需要手动取消设置该位以在更改工作树文件时告诉git ... 强调我的。继续说   此选项可以用作粗略的文件级机制,以忽略跟踪文件中未提交的更改(类似于.gitignore对未跟踪文件所做的操作)。如果需要修改索引中的该文件,Git将失败(正常)。合并提交时;因此,如果假定未跟踪的文件在上游被更改,则您将需要手动处理这种情况。 因此,请记住,您将必须知道对这些文件所做的任何上游更改。 如果您想再次开始跟踪文件,则只需使用
git update-index --no-assume-unchange [ FILE ]
希望对以后的读者有帮助。     ,对于ssh部分,您应该考虑使用Gitolite(替代gitosis)。     ,就像Fred Frodo所说的那样,您可以将私有排除规则放在存储库的“ 2”中。 如果要对计算机上的所有存储库应用相同的排除规则,则可以将以下内容添加到用户目录中的
.gitconfig
文件中。
[core]       
    excludesfile = /home/<myusername>/.gitexclude 
然后将排除模式添加到
~/.gitexclude
。     ,您可能对Junio编写且Carl进行了改进的更新挂钩感兴趣。将下面的代码放在ѭ11中,不要忘了通过ѭ12启用它。
#!/bin/bash

umask 002

# If you are having trouble with this access control hook script
# you can try setting this to true.  It will tell you exactly
# why a user is being allowed/denied access.

verbose=false

# Default shell globbing messes things up downstream
GLOBIGNORE=*

function grant {
  $verbose && echo >&2 \"-Grant-     $1\"
  echo grant
  exit 0
}

function deny {
  $verbose && echo >&2 \"-Deny-      $1\"
  echo deny
  exit 1
}

function info {
  $verbose && echo >&2 \"-Info-      $1\"
}

# Implement generic branch and tag policies.
# - Tags should not be updated once created.
# - Branches should only be fast-forwarded unless their pattern starts with \'+\'
case \"$1\" in
  refs/tags/*)
    git rev-parse --verify -q \"$1\" &&
    deny >/dev/null \"You can\'t overwrite an existing tag\"
    ;;
  refs/heads/*)
    # No rebasing or rewinding
    if expr \"$2\" : \'0*$\' >/dev/null; then
      info \"The branch \'$1\' is new...\"
    else
      # updating -- make sure it is a fast-forward
      mb=$(git-merge-base \"$2\" \"$3\")
      case \"$mb,$2\" in
        \"$2,$mb\") info \"Update is fast-forward\" ;;
    *)    noff=y; info \"This is not a fast-forward update.\";;
      esac
    fi
    ;;
  *)
    deny >/dev/null \\
    \"Branch is not under refs/heads or refs/tags.  What are you trying to do?\"
    ;;
esac

# Implement per-branch controls based on username
allowed_users_file=$GIT_DIR/info/allowed-users
username=$(id -u -n)
info \"The user is: \'$username\'\"

if test -f \"$allowed_users_file\"
then
  rc=$(cat $allowed_users_file | grep -v \'^#\' | grep -v \'^$\' |
    while read heads user_patterns
    do
      # does this rule apply to us?
      head_pattern=${heads#+}
      matchlen=$(expr \"$1\" : \"${head_pattern#+}\")
      test \"$matchlen\" = ${#1} || continue

      # if non-ff,$heads must be with the \'+\' prefix
      test -n \"$noff\" &&
      test \"$head_pattern\" = \"$heads\" && continue

      info \"Found matching head pattern: \'$head_pattern\'\"
      for user_pattern in $user_patterns; do
    info \"Checking user: \'$username\' against pattern: \'$user_pattern\'\"
    matchlen=$(expr \"$username\" : \"$user_pattern\")
    if test \"$matchlen\" = \"${#username}\"
    then
      grant \"Allowing user: \'$username\' with pattern: \'$user_pattern\'\"
    fi
      done
      deny \"The user is not in the access list for this branch\"
    done
  )
  case \"$rc\" in
    grant) grant >/dev/null \"Granting access based on $allowed_users_file\" ;;
    deny)  deny  >/dev/null \"Denying  access based on $allowed_users_file\" ;;
    *) ;;
  esac
fi

allowed_groups_file=$GIT_DIR/info/allowed-groups
groups=$(id -G -n)
info \"The user belongs to the following groups:\"
info \"\'$groups\'\"

if test -f \"$allowed_groups_file\"
then
  rc=$(cat $allowed_groups_file | grep -v \'^#\' | grep -v \'^$\' |
    while read heads group_patterns
    do
      # does this rule apply to us?
      head_pattern=${heads#+}
      matchlen=$(expr \"$1\" : \"${head_pattern#+}\")
      test \"$matchlen\" = ${#1} || continue

      # if non-ff,$heads must be with the \'+\' prefix
      test -n \"$noff\" &&
      test \"$head_pattern\" = \"$heads\" && continue

      info \"Found matching head pattern: \'$head_pattern\'\"
      for group_pattern in $group_patterns; do
    for groupname in $groups; do
      info \"Checking group: \'$groupname\' against pattern: \'$group_pattern\'\"
      matchlen=$(expr \"$groupname\" : \"$group_pattern\")
      if test \"$matchlen\" = \"${#groupname}\"
      then
        grant \"Allowing group: \'$groupname\' with pattern: \'$group_pattern\'\"
      fi
        done
      done
      deny \"None of the user\'s groups are in the access list for this branch\"
    done
  )
  case \"$rc\" in
    grant) grant >/dev/null \"Granting access based on $allowed_groups_file\" ;;
    deny)  deny  >/dev/null \"Denying  access based on $allowed_groups_file\" ;;
    *) ;;
  esac
fi

deny >/dev/null \"There are no more rules to check.  Denying access\"
有了此钩子之后,您便可以为特定的用户或组提供对存储库的更改。可以看到它的其他任何人都具有只读访问权限。   它使用两个文件
$GIT_DIR/info/allowed-users
allowed-groups
来描述哪些头可以由谁推入。每个文件的格式如下:
refs/heads/master  junio
+refs/heads/pu     junio
refs/heads/cogito$ pasky
refs/heads/bw/.*   linus
refs/heads/tmp/.*  .*
refs/tags/v[0-9].* junio
     这样,Linus可以推动或创建
bw/penguin
bw/zebra
bw/panda
分支,Pasky只能执行
cogito
,JC可以执行
master
pu
分支并制作版本标记。任何人都可以做23个分支。
pu
记录上的“ +”号表示JC可以对其进行非快进推送。 如果此人尚未访问您的存储库所在的主机,则该人应仅具有“ 25”访问权限,而不是无限制访问权限。创建一个特殊用途的git用户,并在ѭ26中,以以下形式添加局外人的SSH密钥。请注意,该键应该在一条长线上,但是我将其包裹在下面以帮助演示。 没有代理转发,没有端口转发,没有pty,没有X11转发, 命令= \“ env myorg_git_user = joeuser / usr / local / bin / git-shell -c \\\“ $ {SSH_ORIGINAL_COMMAND:-} \\\” \“ ssh-rsa AAAAB3 ... 2iQ == joeuser@foo.invalid 根据您的本地设置,您可能需要将路径调整为
git-shell
。请记住,
sshd
与about29ѭ目录的权限高度偏执,因此请关闭其组写入位及其下的所有文件。 通过git用户向每个人传递信息意味着您需要能够区分别人,这是
myorg_git_user
环境变量的目的。而不是依赖无条件的
username=$(id -u -n)
,请调整更新挂钩以使用它:
# Implement per-branch controls based on username
allowed_users_file=$GIT_DIR/info/allowed-users
if [ -z \"$myorg_git_user\" ]; then
  username=$(id -u -n)
else
  username=$myorg_git_user
fi
info \"The user is: \'$username\'\"
通过此设置,具有只读访问权限的朋友将使用类似于以下命令的命令克隆。具体路径取决于您的设置。为了使路径更好,可以将您的存储库重新放置到git用户的主目录中,或者创建一个指向它的符号链接。 $ git clone git@blankman.com.invalid:coolproject.git 但将无法进行更新。 $ git push origin mybranch 总计0(增量0),重用0(增量0) 远程:错误:挂钩拒绝更新参考/头/ mybranch 到git@blankman.com.invalid:coolproject.git  ! [远程拒绝] mybranch-> mybranch(挂钩被拒绝) 错误:无法将某些引用推送到\'git@blankman.com.invalid:coolproject.git \' 您说您正在团队环境中工作,所以我假设您的中央存储库是使用
--shared
选项创建的。 (请参阅
git config
文档中的
core.sharedRepository
git init
文档中的
--shared
。)确保新的git用户是系统组的成员,该组允许您所有人访问中央存储库。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-