On Tue, Apr 18, 2023 at 1:03 AM Uwe Brauer <o...@mat.ucm.es> wrote: > > > On Mon, Apr 17, 2023 at 3:05 PM Uwe Brauer <o...@mat.ucm.es> wrote: > > > git push hg-remote > > remotes/origin/modernize:refs/heads/branches/modernize > > Does not push the git branch modernize to the named branch modernize, sorry
It does here. ( git init git-repo cd git-repo echo one > content git add content git commit -m 'one' ) hg init hg-repo ( git clone git-repo proxy-repo cd proxy-repo git remote add -f hg-repo hg::../hg-repo git push hg-repo remotes/origin/master:refs/heads/branches/master ) hg -R hg-repo log changeset: 0:c8ae0e6c7f3e branch: master tag: tip user: Felipe Contreras <felipe.contre...@gmail.com> date: Tue Apr 18 02:08:35 2023 -0600 summary: one > > Only if you don't specify the refspec, which is the typical way to push. > > You mean, in layman terms, checkout the remote branch? No, checking out means putting the contents of a revision in the current working directory. This is true in all version control systems, including Mercurial. An alias for `hg checkout` is `hg update`. You don't need to checkout a branch to push it, just do: `git push foo` (no refspec). > > git push hg-remote hairyblocks > > > That would be translated to a refspec: > > > git push hg-remote > > refs/heads/hairyblocks:refs/heads/branches/hairyblocks > > > But if you are already specifying the refspec, nothing gets translated. > > > > It does, but you haven't created the local branches, soyou can't do > > `git push foo`, if "foo" doesn't exist. > > > > But you are going to need to do that only once. > > So to sum it up: > > 1. If I wish to push (remote) gitbranches as hg named branches, I have > first > to check them out to have local ones? That seems the strategy I > followed from the > start, but then I understand your comments, that I can somehow > save that step your find at least a faster way No, you don't need to check them out. What I suggested was to use `git switch` to *create* them. Yes, `git switch` also checks them out, but that's an unnecessary step. You can skip that step by doing `git branch` instead of `git switch` (or `git checkout`). But it doesn't matter, the important thing is that they get *created*. But as I already explained, you don't even need to create them. > So you suggested > > > git for-each-ref --format='git switch %(refname:lstrip=3)' > > refs/remotes/origin > > > > Or you can push the commit of a remote branch: > > > > git push hg-remote remotes/origin/modernize:modernize > > That this would save me to step to checkout the branches, but > > git push hg-remote remotes/origin/modernize:modernize git push hg-remote remotes/origin/modernize:refs/heads/branches/modernize Not git push hg-remote remotes/origin/modernize:modernize And this is orthogonal to `git switch`: either you *create* the local branches, or you don't. If you create the branches with `git switch` (or `git branch` or whatever), then you don't need to specify the refspec in `git push`. If you do not create the branches, then you need a refspec (as explained above). -- Felipe Contreras -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/CAMP44s2w0%2BR8D7A8UDFvKR2WFz9AVXVa-ojdfyLbXGwY4KBoSg%40mail.gmail.com.