3

I do push to two remote repositories when I do git commit all

[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = [email protected]:kkk_pro/tst1.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [remote "all"] url = [email protected]:kkk_pro/tst2.git fetch = +refs/heads/*:refs/remotes/all/* pushurl = [email protected]:kkk_pro/tst1.git pushurl = [email protected]:kkk_pro/tst2.git 

But when I type git push git pushes only to tst1 ? Why? How to ask git to use all as default remote?

2 Answers 2

1

But when I type git push git pushes only to tst1


How does git decide where to push the code?

Prior to Git version 2 everytime you ececuted git push without specifiying remote all your local branches have been pushed to the remote.

Starting in git v2 you need to specify the origin and the remote whenever you pushed.

Whenever you type git push without remote & branch git will push the branch to the default upstream branch.

You can set the default branch on the remote for the push using:

git push --set-upstream <origin> <branch> 

enter image description here

From your config:

[branch "master"] remote = origin 

You can see that your master is set to be pushed to origin whih is tst1

How to add multiple push urls?

git remote set-url --add --push <origin_name> [email protected]:.../a.git git remote set-url --add --push <origin_name> [email protected]:.../b.git 

How to view the configuration?

git remote show origin 

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

origin is the default remote, just move it there.

From the docs:

When the command line does not specify where to push with the argument, branch.*.remote configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to origin.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.