mihral
mihral

Reputation: 353

Push commits to multiple remotes

I forked a repository and committed some files and created a pull request to origin repository.

Is it possible if I make other changes in files to push only to my local copy of the original repository? So the commits to not appear on the original repository.

I see that with git push origin master I see my commits in the original repository.

Thank you

Upvotes: 0

Views: 36

Answers (1)

CodeWizard
CodeWizard

Reputation: 142632

Is it possible if I make other changes in files to push only to my local copy of the original repository?

You should add multiple remotes if you don't have them yet.

How to add new remote?

git remote add <remote_name> url 

Now you can push your branch to any remote

git push <remote_name> master

How to get the list of all remotes?

git remote --vv

If you want the push the same ranch to multiple remotes you can do this:

git remote set-url --add --push origin <url1>
git remote set-url --add --push origin <url2>

Your .git/config should look like:

[remote "origin"]
    url = git://original/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    pushurl = git://original/repo.git
    pushurl = git://another/repo.git

Upvotes: 1

Related Questions