git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Branches, upstreams, rebases and logistics
@ 2021-03-30 20:28 stdedos
  2021-03-31 11:32 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: stdedos @ 2021-03-30 20:28 UTC (permalink / raw)
  To: git; +Cc: stdedos+git, sandals

I was reading this thread:
https://lore.kernel.org/git/YFP+KuUn99vftBIC@camp.crustytoothpaste.net/

and, in specific:
> ..., many fixup and squash commits and near constant rebases.

which speaks to me somewhat heavily.

As this could be a discussion forum, I'd like to see
how other people are dealing with / have done for these:

I clone a repository, I do changes on top of a branch,
I push for review, ... and the cycle continues until merging.

It is trivial, when native `git push/pull` is used to push/pull
to/from one remote which I have access, as `pull --rebase` works
magically in keeping the local state up-to-date.

It also works with the repos that you do not have direct access to
push natively on the branch nowhere, as you can keep using the
`pull --rebase` to sync, and "push" with some other method
(`refs/for`, `git-send-email`, or others which I don't know).

However, with the Github way of working, that means:
I have two remotes, (origin and upstream), on which, I develop and
push on the `origin`, but I am really tracking/rebasing on/from `upstream`.

I cannot `--track` upstream, as plain `git push` won't work, and
for pull, I have to separately `git fetch --all`, `git rebase upstream/<branch>`

- OR -

I have a branch, which depends on top of another branch (not yet merged upstream).

o - origin/master
 \
  o---o---o---o
  |            \
  fix/local     o--o - (fix/depends-on-local)

For brevity, I am setting "git branch --set-upstream-to=fix/local",
which helps, when rebasing fix/local on top of origin/master, to rebase
fix/depends-on-local on top of fix/local.

However, as noted above, a branch cannot be pushed upstream easily and
have a different upstream set at the same time.

I know my logic/understanding is lacking somewhere;
I am looking forward to enlightenment :-D

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Branches, upstreams, rebases and logistics
  2021-03-30 20:28 Branches, upstreams, rebases and logistics stdedos
@ 2021-03-31 11:32 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2021-03-31 11:32 UTC (permalink / raw)
  To: stdedos; +Cc: git, stdedos+git, sandals

On Tue, Mar 30, 2021 at 11:28:52PM +0300, stdedos@gmail.com wrote:

> However, with the Github way of working, that means:
> I have two remotes, (origin and upstream), on which, I develop and
> push on the `origin`, but I am really tracking/rebasing on/from `upstream`.
> 
> I cannot `--track` upstream, as plain `git push` won't work, and
> for pull, I have to separately `git fetch --all`, `git rebase upstream/<branch>`
> 
> - OR -
> 
> I have a branch, which depends on top of another branch (not yet merged upstream).
> 
> o - origin/master
>  \
>   o---o---o---o
>   |            \
>   fix/local     o--o - (fix/depends-on-local)
> 
> For brevity, I am setting "git branch --set-upstream-to=fix/local",
> which helps, when rebasing fix/local on top of origin/master, to rebase
> fix/depends-on-local on top of fix/local.
> 
> However, as noted above, a branch cannot be pushed upstream easily and
> have a different upstream set at the same time.

This is usually called a "triangular" workflow; you can find some
discussion in the list archive and documentation by searching for that
term.

But in short, what you probably want is to set:

  git config remote.pushdefault yourfork

(I'm not entirely sure, but I think "yourfork" is "origin" in your
example). Which means that "git push" will behave as you'd like, pushing
to your fork. And you are free to set the "upstream" of each branch to
the thing it is based on (again, assuming your "upstream" remote is the
actual upstream project that you can't push to):

  git branch --set-upstream-to=upstream/master fix/local
  git branch --set-upstream-to=fix/local fix/depends-on-local

And then from either "fix/local" or "fix/depends-on-local" branches, you
can "git pull --rebase" (or in the case of the latter, just "git rebase"
would do the same thing).

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-31 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30 20:28 Branches, upstreams, rebases and logistics stdedos
2021-03-31 11:32 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).