Matthew Dresser Matthew Dresser - 3 months ago 31
Git Question

Git push master branch to secondary remote

I have an existing git repository hosted on my company's online git account. I now want to set up a second remote within my client's online git account. I want to keep my company's repository as the primary day-to-day means of sharing code and the client's one just with the master branch for the current releases.

I have used

git remote add <clientName> <clientRepoUrl>

to add the new remote in my git config file.

I can use

git push <clientName> --all # pushes up the repo and its refs for the first time

to push the whole repo to the new remote.

But what if I omit the
parameter? How will the merge commits to the master branch show up? Will this actually work properly?


But what if I omit the --all parameter?

You can simply push only master (git push origin master) to the second remote repo.
That will include all commits accessible from master, including the merge commits parents.

x--x--x--x--M --x (master)
    \      /
     y----y       (branchY)

Pushing master only would push y commits, even though the reference branchY itself would not be pushed.