Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't appear to push to multiple remotes, unlike git push #1306

Open
skyfaller opened this issue Aug 31, 2022 · 7 comments
Open

Doesn't appear to push to multiple remotes, unlike git push #1306

skyfaller opened this issue Aug 31, 2022 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@skyfaller
Copy link

skyfaller commented Aug 31, 2022

Describe the bug
I have multiple git remotes, as described in https://seirdy.one/posts/2020/11/18/git-workflow-1/

The repo in question is https://git.sr.ht/~skyfaller/twentyeleven-skyfaller

My .git/config looks like this:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = git@git.sr.ht:~skyfaller/twentyeleven-skyfaller
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@codeberg.org:skyfaller/twentyeleven-skyfaller.git
	url = git@github.com:skyfaller/twentyeleven-skyfaller.git
[branch "master"]
	remote = origin
	merge = refs/heads/master
[remote "gh_mirror"]
	url = git@github.com:skyfaller/twentyeleven-skyfaller.git
	fetch = +refs/heads/*:refs/remotes/gh_mirror/*
[remote "cb_mirror"]
	url = git@codeberg.org:skyfaller/twentyeleven-skyfaller.git
	fetch = +refs/heads/*:refs/remotes/cb_mirror/*

When I make changes to my git repo, and use gitui to Push [p], it only pushes to one remote, in this case GitHub / gh_mirror.

It appears it pushes to the remote which is listed last. This doesn't parallel git's behavior, git prioritizes the URL that is listed first when pulling:

> git pull origin -v
From git.sr.ht:~skyfaller/twentyeleven-skyfaller
 = [up to date]      master     -> origin/master
 = [up to date]      static     -> origin/static
Already up to date.

But since gitui should push to all of the URLs rather than picking one anyway, this isn't important.

When I use git push after using gitui to push, I see:

> git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 468 bytes | 468.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
To git.sr.ht:~skyfaller/twentyeleven-skyfaller
   e714d73..0370dee  master -> master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 468 bytes | 468.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To codeberg.org:skyfaller/twentyeleven-skyfaller.git
   e714d73..0370dee  master -> master
Everything up-to-date

As you can see, git push is successfully pushing to the other remotes that gitui did not.

Expected behavior
I expect the behavior of git push and gitui's "Push" function to be identical.

Context (please complete the following information):

  • OS/Distro + Version: Fedora Linux 36 (Workstation Edition) x86_64
  • GitUI Version: gitui 0.21.0 (installed from Linuxbrew)
@skyfaller skyfaller added the bug Something isn't working label Aug 31, 2022
@extrawurst
Copy link
Owner

oh wow I had no idea I could have it push to two remotes at the same time. TIL

@extrawurst extrawurst added feature-request bug Something isn't working and removed bug Something isn't working feature-request labels Sep 2, 2022
@skyfaller
Copy link
Author

skyfaller commented Sep 7, 2022

If you're curious, it doesn't appear to make a difference if I use pushurl instead, as suggested in https://brandonrozek.com/blog/git-pushing-multiple-remotes/. Something like this still results in gitui only pushing to one of the remotes:

[remote "origin"]
        url = git@github.com:Brandon-Rozek/website.git 
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = git@github.com:Brandon-Rozek/website.git
        pushurl = git@git.sr.ht:~brandonrozek/website

I personally prefer to have them all as url, it saves one duplicated line in the config and aesthetically I like them all looking equal, but if the ultimate fix required pushurl for some reason, I'm sure I would get over it.

@extrawurst
Copy link
Owner

Open for PRs :)

@stale
Copy link

stale bot commented Mar 18, 2023

This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the dormant Marked by stale bot on close label Mar 18, 2023
@skyfaller
Copy link
Author

skyfaller commented Mar 27, 2023

I've learned that I can fetch updates from all my remotes with:

> git pull --all
Fetching origin
Fetching cb_mirror
Fetching gh_mirror
Already up to date.

This doesn't actually pull from more than one remote, it's only fetching updates from the non-"origin" remotes, but I don't usually use git fetch in my workflow so this is easier to remember, and then at least I'll see if there are updates in other remotes which I can then integrate into the "origin".

I also usually push with:

> git push --all
Everything up-to-date
Everything up-to-date
Everything up-to-date

It's easy to forget to push other branches when working with multiple remotes, so even if git push --all shouldn't be necessary for pushing the branch I'm working on to other remotes, this helps make sure I keep the remotes in sync.

Frankly I don't fully understand Seirdy's (excessively complex?) git aliases and I don't use them.

@stale stale bot removed the dormant Marked by stale bot on close label Mar 27, 2023
@stale stale bot added the dormant Marked by stale bot on close label Oct 15, 2023
Repository owner deleted a comment from stale bot Oct 15, 2023
@extrawurst extrawurst removed the dormant Marked by stale bot on close label Oct 15, 2023
@semioticrobotic
Copy link
Contributor

semioticrobotic commented Nov 22, 2023

Would love to see functionality for pushing to multiple remote branches implemented. Like @skyfaller, I have projects with multiple remotes, but gitui seems unable to work with them (it crashes with pushing in these projects).

My ideal behavior would be: Press p to push changes and receive a dialog box asking which remote to push to.

But minimal desirable behavior would be something like @skyfaller suggests: git push --all as default behavior.

@extrawurst extrawurst added the help wanted Extra attention is needed label Feb 27, 2024
@extrawurst
Copy link
Owner

unfortunatelty libgit2 does not seem to support remotes with multiple url or pushurl: https://libgit2.org/libgit2/#HEAD/group/remote/git_remote_set_pushurl

This assumes the common case of a single-url remote and will otherwise return an error.

we have to add that upstream first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants