Re: Git Commit Notes (fetching/pushing)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hy Junio, thanks.

A few important lessons learned here (in case it helps others):

1. Use `push = refs/heads/*:refs/heads/*` when pushing (this is what made everything work for me). Especially since my host is GitHub in this situation and I don't have control to the remote working tree as you point out.
2. Don't use the `+` prefix for fetches and pushes as you point out. I didn't realize the value of this prefix until now, especially since this seems to be default behavior when cloning a repository so I was mostly following the default syntax.

Here's my working configuration based on your feedback:

[remote "origin"]
  url = https://github.com/bkuhlmann/test
  fetch = +refs/heads/*:refs/remotes/origin/*
  fetch = refs/notes/*:refs/notes/*
  fetch = refs/tags/*:refs/tags/*
  push = refs/heads/*:refs/heads/*
  push = refs/notes/*:refs/notes/*
  push = refs/tags/*:refs/tags/*

I'm a heavy rebaser (only on feature branches, never `main`) so definitely don't wish to clobber work accidentally even when using `git push --force-with-lease` or the `push.useForceIfIncludes = true` configuration setting.

One interesting side-effect that I've noticed with all of these changes is that my `branch.autoSetupRebase = always` configuration no longer knows how to automatically setup tracking for new feature branches when using `git switch --create <example>`. Even using the `-t` flag doesn't quite work either. I'll need to tinker with this some more.

Otherwise, all of this appears to be working nicely as I can push/pull to my repository and then clone the same repository at a different location on disk and see all of my branches and notes sync appear properly.

Thanks again, this has been great to learn!

> On Aug 7, 2023, at 10:14 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> 
> Brooke Kuhlmann <brooke@xxxxxxxxxxxxx> writes:
> 
>> I ended up using the following configuration in order to
>> explicitly fetch/push branches, notes, and tags:
>> 
>> [remote "origin"]
>> url = https://github.com/bkuhlmann/test
>> fetch = +refs/heads/*:refs/remotes/origin/*
>> fetch = +refs/notes/*:refs/notes/*
>> fetch = +refs/tags/*:refs/tags/*
>> push = +refs/heads/*:refs/remotes/origin/*
> 
> This will push your local branches (e.g. refs/heads/xyzzy) to their
> remote-tracking branches (e.g. refs/remotes/origin/xyzzy) of the
> same name.  Is that what you meant?  It is unclear what kind of use
> you have your remote repository for, and in some use cases, it is
> perfectly valid if a push from here is used as a substitute for a
> fetch from there to arrange the push from here like how you have
> above, to push into refs/remotes/origin/* of a remote repository
> with a working tree.
> 
> But often, a remote is used as a publishing point (i.e. everybody
> pulls from and only you push into it) or as a central meeting place
> (i.e. everybody pulls from and pushes into it), and in these cases,
> a push refspec would look more like
> 
> push = refs/heads/*:refs/heads/*
> 
> This is especially true when the remote is a bare repository, or
> hosted at a hosting site you or nobody has access to its working
> tree.
> 
> Note the lack of leading '+'; that is absolutely essential if you
> are pushing into a central meeting place because you want to avoid
> force pushing that will clobber others' work, and it is also a great
> discipline even if you are pushing into your publishing point
> because those in your downstream will be disrupted if you rewind
> your history.
> 
> 





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux