4

I am trying to add multiple push URLs in Gitkraken and it doesn't seem to work. In Sourcetree or command line I just add:

[remote "origin"]
   url = git@blah:blah/blah.git
   fetch = +refs/heads/*:refs/remotes/origin/*
   pushurl = git@blah:blah/blah.git
   pushurl = git@blah2:blah/blah.git

When I do this in via command line Gitkraken only pushes to the last repository and in the settings it is the only push URL shown. Still works via command line, but the point of using Gitkraken is so I can just click the push button rather than type the command each time. Any ideas?

user2395126
  • 526
  • 1
  • 7
  • 20
  • I couldn get this to work on gitkraken, but a bash based solution can be found at https://stackoverflow.com/a/3195446 – pvl Jan 15 '19 at 10:27

2 Answers2

5

I know this is an old question, but just in case it still gets views.

I haven't found a good solution in GitKraken to directly do what you are looking for, HOWEVER, you can add a second remote.

To do this hover over "Remote" in the left menu and click the (+) next to the remote. From here you can add your second remote repository.

After your repos are added you can right click on your local and select "Set Upstream" and choose which one you are pointing to.

Once you push to that, you can reset the upstream to the second repo and repeat the push.

I know it's not as shiny as what you're asking for, but it seems to be one of the best solutions for multiple remote repos.

SegfaultZ
  • 51
  • 1
  • 4
0

I ran into the same problem with GitKraken when adding multiple push URLs to a single remote. The issue seems to be tied to how GitKraken internally chooses the push URL to use when pressing the Push button.

Through some experimentation I found that GitKraken always defaulted to the last push URL listed in the config when viewing "git remote -v". There doesn't seem to be any way to get that button to use multiple URLs, even if properly entered in the config. You can also see that the last push URL in the config matches the push URL seen in the GUI for that remote.

.....

UPDATE / RECOMMENDATION

I ultimately decided not to use multiple push URLs. Since I couldn't push changes to both remotes simultaneously using the Push button, I was concerned I would forget to push to the additional repo via terminal. There wasn't any advantage to using multiple push URLs if I had to use the terminal as a secondary step.

Instead I simply added my additional remote and am now pushing to it manually via terminal. I'm using the push button in GitKraken first to push to the primary remote, and then am opening up the terminal to push to the additional remote. The main reason this is better is that by having the additional remote(s) actually added in GitKraken, you can see where that remote is relative to the other remote and local. It acts as a constant reminder of the additional remote, so you don't forget to push to it as well.

I think this is also safer than pushing to two remotes simultaneously. Even if it did work in GitKraken, you would have no indicator that the push completed to the additional remote since it occurs in the background. Having the additional remote(s) added in the GUI makes a lot more sense to keep them in sync. Yes, you will need to push to those remotes separately, but at least you can see them this way and know which commit they are at.

If anyone reads this, that is what I recommend. Forget about pushing to multiple remotes at once. It isn't as advantageous as you may think.