I work with Gerritt and need some help in automating a manual step in our code check in process. Here is the background. When I clony my repo afresh, here is what I see in my Git config (inside .git folder).
[remote "origin"]
url = https://[email protected]/contentpipeline.git
fetch = +refs/heads/*:refs/remotes/origin/*
We make the following change manually in the git config. (Ref 2nd line)
[remote "origin"]
push = +refs/heads/MYBRANCH:refs/for/MYBRANCH
url = https://[email protected]/contentpipeline.git
fetch = +refs/heads/*:refs/remotes/origin/*
The line with push is added so that the change is not directly pushed to MYBRANCH but is treated as 'Push for Review'.
I have 2 questions:
- Can this manual addition be automated using a git CLI command.
- We are using a NOde JS framework simple-git (https://www.npmjs.com/package/simple-git?activeTab=readme) to automate this process. Can this be done using simple-git as well.
Thanks a lot, Prabal
Any setting in git config can be added using
git config [path.to.setting] [value].In your case:
Check
git help configfor all the nitty gritty details of how to edit your configuration.simple-gitis just a wrapper on top ofgitcommand line tool, so yes, you can run the exact same command usingsimple-git-- I will let you refer to the documentation to find out how.for the sake of illustration:
Also, as stated in the comments, if you want to set a refspec that works for all branches (not just
MYBRANCH), you can use :