Search code examples
gitshellversion-controlterminalchaining

How to clone using git and chain git config user.name


I want to do command chaining with git. I want exactly to clone a repo then set the configurations for that working copy changing user.name, user.email.

I tried this:

git clone https://repoUrl.git && git config user.name "Khaled" && git config user.email "[email protected]"

But I got this error:

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

Solution

  • Using @torek comment this problem was fixed. git clone really puts its clone into a new directory and I needed to cd into it before calling the configs so here is the fixed version:

    git clone https://repoUrl.git customDirectory && cd customDirectory && git config user.name "Khaled" && git config user.email "[email protected]"