* Rebase
@ 2025-01-19 5:29 Al Grant
2025-01-19 16:21 ` Rebase brian m. carlson
0 siblings, 1 reply; 6+ messages in thread
From: Al Grant @ 2025-01-19 5:29 UTC (permalink / raw)
To: git
Hello,
I am looking for some assistance rebasing please.
I have a feature branch which has the many recent commits and a main
branch which has not had a commit for a long time. I want to make the
code in the feature branch the code in the main branch.
I think a rebase is the command I need, but the exact steps I am not sure of.
I did try this:
1. Sync both branches with remote (github)
2. git checkout feature
3. git rebase main
That resulted in the following perge conflicts:
PS C:\Users\AlGrant\andrej_branch\test_fft> git rebase main
error: could not apply 1f893dc... Make project runnable on Linux
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git
rebase --abort".
Could not apply 1f893dc... Make project runnable on Linux
Auto-merging src/kiwitracker/sample_processor.py
CONFLICT (content): Merge conflict in src/kiwitracker/sample_processor.py
Auto-merging src/kiwitracker/common.py
CONFLICT (content): Merge conflict in src/kiwitracker/common.py
PS C:\Users\AlGrant\andrej_branch\test_fft> git rebase --abort
Which I have now aborted. I dont understand why I even have to deal
with merge conflicts when I want to keep the code in feature and make
it main.
Help.
Thanks
Al
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rebase
2025-01-19 5:29 Rebase Al Grant
@ 2025-01-19 16:21 ` brian m. carlson
[not found] ` <CAODtcdf-+QpPpB5R-hLkKWKacwM=N3=XRDs-tK60W9WzUJu7xw@mail.gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: brian m. carlson @ 2025-01-19 16:21 UTC (permalink / raw)
To: Al Grant; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]
On 2025-01-19 at 05:29:09, Al Grant wrote:
> Hello,
>
> I am looking for some assistance rebasing please.
>
> I have a feature branch which has the many recent commits and a main
> branch which has not had a commit for a long time. I want to make the
> code in the feature branch the code in the main branch.
>
> I think a rebase is the command I need, but the exact steps I am not sure of.
>
> I did try this:
>
> 1. Sync both branches with remote (github)
> 2. git checkout feature
> 3. git rebase main
If you just want to make the branches completely identical, you can do
this:
----
$ git checkout feature
$ git update-ref refs/heads/main $(git rev-parse --verify refs/heads/feature)
----
That will make `main` the exact same commit as `feature`. Note that you
don't want to be on the destination branch (in this case, `main`) when
you do the `git update-ref` call because that will result in the index
being out of sync with the commit.
You could also do this:
----
$ git checkout main
$ git reset --hard feature
----
That will update `main` and the working tree to be completely identical
to `feature`. Please note that it will also completely and
irrecoverably destroy changes in any modified files in the working tree,
so you may prefer the first option, which is a little safer.
In either case, if there are changes in the `main` branch which are not
in the `feature` branch, this will remove them. What I gave you above
will make them completely identical in every way, including in terms of
history.
If you want to preserve some of those changes, then you do need a
rebase, and the commands you gave are correct. You will then need to
resolve the merge conflicts in each conflicting commit and continue the
rebase each time.
--
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rebase
[not found] ` <CAODtcdf-+QpPpB5R-hLkKWKacwM=N3=XRDs-tK60W9WzUJu7xw@mail.gmail.com>
@ 2025-01-19 20:39 ` Al Grant
2025-01-19 23:08 ` Rebase D. Ben Knoble
2025-01-20 1:32 ` Rebase brian m. carlson
0 siblings, 2 replies; 6+ messages in thread
From: Al Grant @ 2025-01-19 20:39 UTC (permalink / raw)
To: brian m. carlson, Al Grant, git
Yes. But I'm keen to understand how to deal with a merge conflict.
My IDE is VSCode and when I run the merge I get this image:
https://imgur.com/a/vynTxaj
Which highlights this code:
255: <<<<<<< HEAD
256: samples = signal.convolve(samples, [1]*189, 'same')/189
257:
258: #for testing - log to file
259: #self.f.write(samples.astype(np.float32).tobytes())
260:
261:=======
262: samples = signal.convolve(samples, [1] * 10, "same") / 189
263:
264: # for testing - log to file
265: # self.f.write(samples.astype(np.float32).tobytes())
266:
267:>>>>>>> 1f893dc (Make project runnable on Linux)
Now I would assume that samples = .... from ln 256 abd 262 are the
differences between MAIN and FEATURE?
But when I search main (at least I think its main - my IDE doesnt tell
me mid rebase process) for ` samples = signal.convolve(samples,
[1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *
10, "same") / 189` - those lines do not exists anywhere in MAIN???
So what is going on????
Al
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rebase
2025-01-19 20:39 ` Rebase Al Grant
@ 2025-01-19 23:08 ` D. Ben Knoble
2025-01-20 1:32 ` Rebase brian m. carlson
1 sibling, 0 replies; 6+ messages in thread
From: D. Ben Knoble @ 2025-01-19 23:08 UTC (permalink / raw)
To: Al Grant; +Cc: brian m. carlson, git
On Sun, Jan 19, 2025 at 3:39 PM Al Grant <bigal.nz@gmail.com> wrote:
>
> Yes. But I'm keen to understand how to deal with a merge conflict.
[and also]
> Which I have now aborted. I dont understand why I even have to deal
with merge conflicts when I want to keep the code in feature and make
it main.
I recommend reading the book, esp.
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts.
There is also an advanced section
https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging.
As for why you get a merge conflict when rebasing, see for example the
StackOverflow about rebase using a 3-way merge
(https://stackoverflow.com/q/36993683/4400820) or part of the
remembering-renames documentation
(https://git-scm.com/docs/remembering-renames, but it renders poorly,
so also try `open $(git
--html-path)/technical/remembering-renames.txt`, substituting `open`
for your platform equivalent).
--
D. Ben Knoble
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rebase
2025-01-19 20:39 ` Rebase Al Grant
2025-01-19 23:08 ` Rebase D. Ben Knoble
@ 2025-01-20 1:32 ` brian m. carlson
2025-01-20 21:15 ` Rebase Al Grant
1 sibling, 1 reply; 6+ messages in thread
From: brian m. carlson @ 2025-01-20 1:32 UTC (permalink / raw)
To: Al Grant; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 2385 bytes --]
On 2025-01-19 at 20:39:13, Al Grant wrote:
> Yes. But I'm keen to understand how to deal with a merge conflict.
>
> My IDE is VSCode and when I run the merge I get this image:
>
> https://imgur.com/a/vynTxaj
>
> Which highlights this code:
>
> 255: <<<<<<< HEAD
> 256: samples = signal.convolve(samples, [1]*189, 'same')/189
> 257:
> 258: #for testing - log to file
> 259: #self.f.write(samples.astype(np.float32).tobytes())
> 260:
> 261:=======
> 262: samples = signal.convolve(samples, [1] * 10, "same") / 189
> 263:
> 264: # for testing - log to file
> 265: # self.f.write(samples.astype(np.float32).tobytes())
> 266:
> 267:>>>>>>> 1f893dc (Make project runnable on Linux)
>
> Now I would assume that samples = .... from ln 256 abd 262 are the
> differences between MAIN and FEATURE?
>
> But when I search main (at least I think its main - my IDE doesnt tell
> me mid rebase process) for ` samples = signal.convolve(samples,
> [1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *
> 10, "same") / 189` - those lines do not exists anywhere in MAIN???
>
> So what is going on????
First, I recommend that you set the `merge.conflictStyle` setting to
`diff3` so that you get the contents of the merge base as well. That
can be illustrative when you have conflicts.
It's important to note that a rebase involves replaying individual
commits from one branch on top of another, usually using a merge
algorithm. That means that it isn't necessarily the case during a
rebase that one side is the complete base branch, but rather one side is
the base branch _with all of the previous commits you've rebased on top
of it_.
So if you have this:
A - B - C - D - E - F (main)
\
- G - H - I - J (feature)
and you rebase `feature` on to `main`, you're going to replay G, H, I,
and J (in that order) on top of F. So it might not be that the code
exists in `main`, but that it comes from one of those intermediate
commits.
In this case, the conflict should be trivial to fix up in that the code
appears (at least to a first glance) to be logically equivalent. I
would personally resolve this conflict in favour of the version with a
little more whitespace, since that seems nicer to read.
--
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Rebase
2025-01-20 1:32 ` Rebase brian m. carlson
@ 2025-01-20 21:15 ` Al Grant
0 siblings, 0 replies; 6+ messages in thread
From: Al Grant @ 2025-01-20 21:15 UTC (permalink / raw)
To: brian m. carlson, Al Grant, git
Thank you for the explanation.
I think in this case, what happened was I created the branch without
doing a git push - and so local and remote were not in sync. when I
created the feature branch.
Then when I went to put the feature branch on to main it complained
about the merge because two lines on main were different.
Does that make any sense?
Regards,
Al
On Mon, Jan 20, 2025 at 2:32 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2025-01-19 at 20:39:13, Al Grant wrote:
> > Yes. But I'm keen to understand how to deal with a merge conflict.
> >
> > My IDE is VSCode and when I run the merge I get this image:
> >
> > https://imgur.com/a/vynTxaj
> >
> > Which highlights this code:
> >
> > 255: <<<<<<< HEAD
> > 256: samples = signal.convolve(samples, [1]*189, 'same')/189
> > 257:
> > 258: #for testing - log to file
> > 259: #self.f.write(samples.astype(np.float32).tobytes())
> > 260:
> > 261:=======
> > 262: samples = signal.convolve(samples, [1] * 10, "same") / 189
> > 263:
> > 264: # for testing - log to file
> > 265: # self.f.write(samples.astype(np.float32).tobytes())
> > 266:
> > 267:>>>>>>> 1f893dc (Make project runnable on Linux)
> >
> > Now I would assume that samples = .... from ln 256 abd 262 are the
> > differences between MAIN and FEATURE?
> >
> > But when I search main (at least I think its main - my IDE doesnt tell
> > me mid rebase process) for ` samples = signal.convolve(samples,
> > [1]*189, 'same')/189` AND `samples = signal.convolve(samples, [1] *
> > 10, "same") / 189` - those lines do not exists anywhere in MAIN???
> >
> > So what is going on????
>
> First, I recommend that you set the `merge.conflictStyle` setting to
> `diff3` so that you get the contents of the merge base as well. That
> can be illustrative when you have conflicts.
>
> It's important to note that a rebase involves replaying individual
> commits from one branch on top of another, usually using a merge
> algorithm. That means that it isn't necessarily the case during a
> rebase that one side is the complete base branch, but rather one side is
> the base branch _with all of the previous commits you've rebased on top
> of it_.
>
> So if you have this:
>
> A - B - C - D - E - F (main)
> \
> - G - H - I - J (feature)
>
> and you rebase `feature` on to `main`, you're going to replay G, H, I,
> and J (in that order) on top of F. So it might not be that the code
> exists in `main`, but that it comes from one of those intermediate
> commits.
>
> In this case, the conflict should be trivial to fix up in that the code
> appears (at least to a first glance) to be logically equivalent. I
> would personally resolve this conflict in favour of the version with a
> little more whitespace, since that seems nicer to read.
> --
> brian m. carlson (they/them or he/him)
> Toronto, Ontario, CA
--
"Beat it punk!"
- Clint Eastwood
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-20 21:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-19 5:29 Rebase Al Grant
2025-01-19 16:21 ` Rebase brian m. carlson
[not found] ` <CAODtcdf-+QpPpB5R-hLkKWKacwM=N3=XRDs-tK60W9WzUJu7xw@mail.gmail.com>
2025-01-19 20:39 ` Rebase Al Grant
2025-01-19 23:08 ` Rebase D. Ben Knoble
2025-01-20 1:32 ` Rebase brian m. carlson
2025-01-20 21:15 ` Rebase Al Grant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox