Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins git plugin: How to configure different fetch and push git remotes?

I have a Jenkins project which has a git checkout url. The Jenkins master is configured with git-Jenkins plugin version 2.2.10_2 (https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin).

I wanted to check if there is any way to provide different git remotes for fetch and push.

e.g: $ git remote -v
origin  git@<read-only-git>.com:org/repo.git (fetch) 
origin  git@<read-write-git>.com:org/repo.git (push) 

The use case here is to use a read only source for clones and push any changes back to a read-write source. There is an external synchronization mechanism to update the read only copy.

Thank you,

-Mayur

like image 563
mayurva Avatar asked Feb 02 '26 19:02

mayurva


1 Answers

Use the --push option of git remote set-url.

Assuming you'd cloned from the read-only repo:

Before

$ git remote -v
origin  git@<read-only-git>.com:org/repo.git (fetch) 
origin  git@<read-only-git>.com:org/repo.git (push) 

Command

git remote set-url --push origin git@<read-write-git>.com:org/repo.git

After

$ git remote -v
origin  git@<read-only-git>.com:org/repo.git (fetch) 
origin  git@<read-write-git>.com:org/repo.git (push) 
like image 120
Paul Hicks Avatar answered Feb 05 '26 09:02

Paul Hicks