【问题标题】:How to clone using git and chain git config user.name如何使用 git 克隆和链 git config user.name
【发布时间】:2018-08-30 02:34:27
【问题描述】:

我想用 git 做命令链。我想完全克隆一个 repo,然后为该工作副本设置配置,更改 user.name、user.email。

我试过这个:

git clone https://repoUrl.git && git config user.name "Khaled" && git config user.email "test@server.com"

但是我收到了这个错误:

error: could not lock config file .git/config: No such file or directory

【问题讨论】:

  • git clone 默认将其克隆放入新目录。在对新克隆执行其他操作之前,您必须将 cd 放入该目录。
  • 谢谢。没错。我忘记了。

标签: git shell version-control terminal chaining


【解决方案1】:

克隆后你没有在 gitdir 文件夹中,请关注。

1) git clone https://repoUrl.git

现在你需要进入repo dir

2) cd gitfolder

3) git config user.name "Khaled" && git config user.email "test@server.com"

【讨论】:

  • 这是关于将命令链接在一行中。你是在不同的命令上完成的。
  • 在cmd中添加行&& cd gitfolder
【解决方案2】:

使用@torek 评论解决了这个问题。 git clone 真的把它的克隆放到了一个新目录中,我需要在调用配置之前 cd 进入它,所以这里是固定版本:

git clone https://repoUrl.git customDirectory && cd customDirectory && git config user.name "Khaled" && git config user.email "test@mail.com"

【讨论】:

    【解决方案3】:

    尝试使用它对我有用:-

    git clone https://github.com/rtyley/small-test-repo.git && git config --global user.name "name" && git config --global user.email "xxxxxxx@gmail.com" 
    

    【讨论】:

      【解决方案4】:
      git clone --config key1=value1 --config key2=value2 https://git.com/repo.git
      

      请参考:https://git-scm.com/docs/git-clone

      【讨论】:

        猜你喜欢
        • 2012-07-31
        • 1970-01-01
        • 1970-01-01
        • 2023-03-27
        • 1970-01-01
        • 2020-08-20
        • 1970-01-01
        • 1970-01-01
        • 2011-05-11
        相关资源
        最近更新 更多