Search code examples
androidgitgithubqualcomm

git remote add command : How to edit remote tag in the .git/config file?


I'm currently working on gerrit setup to configure CAF repo to local server. I have come across one problem. The problem is whatever latest version of android I have download from CAF repo, it contains the following tag in .git/config file for remote.

[remote "caf"]
url = https://source.codeaurora.org/quic/la/kernel/msm-3.18.git
review = codeaurora.org
projectname = kernel/msm-3.18
fetch = +refs/heads/*:refs/remotes/caf/*

Now I want to use this repo with local gerrit server therefore I need to use [remote "origin"] as remote instead of [remote "caf"] and for that, I have supplied

git remote add origin ssh://XYZ@IP:PORT/qualcomm_625/kernel/msm-3.18.git

after that in the above config file new content are append like follow,

[remote "origin"]
url = ssh://XYZ@IP:PORT/qualcomm_625/kernel/msm-3.18.git
fetch = +refs/heads/*:refs/remotes/origin/*

how can I add two missing "projectname" "review" lines using git remote add command?


Solution

  • You can add the custom values using git config.

    1. Add your new origin: git remote add origin path/to/repo.git
    2. Add the custom configuration using: git config remote.origin.review review-data

    So in your case, to apply the same extra configuration as the example:

    [remote "caf"]
    url = https://source.codeaurora.org/quic/la/kernel/msm-3.18.git
    review = codeaurora.org
    projectname = kernel/msm-3.18
    fetch = +refs/heads/*:refs/remotes/caf/*
    

    You can run the following commands:

    1. git remote add origin ssh://XYZ@IP:PORT/qualcomm_625/kernel/msm-3.18.git
    2. git config remote.origin.review codeaurora.org
    3. git config remote.origin.projectname kernel/msm-3.18

    You will get the new extra remote:

    [remote "origin"]
    url = ssh://XYZ@IP:PORT/qualcomm_625/kernel/msm-3.18.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    review = codeaurora.org
    projectname = kernel/msm-3.18
    

    Hope it helps!