admin管理员组文章数量:1319477
I have a feature branch 23-fft-channelizer
and a main
branch. 23-fft-channelizer
is way ahead of main
and main
has either had no commits or maybe just the readme in the life of 23-fft-channelizer
.
I now want to rebase 23-fft-channelizer
on to main
and basically want 23-fft-channelizer
to overwrite what's in main
since it 23-fft-channelizer
is the most up to date and working branch.
I would however want to keep the history of main
in case I ever need to refer back to it.
REMOTE REPO
.py
ENVIROMENT
I am using VSCode for my IDE and on a Windows OS.
STEPS SO FAR
- Made a backup copy of branch
23-fft-channelizer
in case anything goes wrong. - Sync'd both
main
and23-fft-channelizer
with remote repo. (git pull
on each main/feature - response was up to date on both) - Made sure both are saved to local disk.
- git rebase main
Now this is where the issues start. I get a conflict with the option to resolve in the VSCode IDE about which code to accept. It looks like this:
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)
ISSUE
Neither of those lines can I find in the current local copy of that file, but it does exist on the repo at .py#L240
Q: So what is going on - why is that line not on my local copy and how can I resolve this?
Q: Are the two code snippets above diff's between two versions of main
?
I have a feature branch 23-fft-channelizer
and a main
branch. 23-fft-channelizer
is way ahead of main
and main
has either had no commits or maybe just the readme in the life of 23-fft-channelizer
.
I now want to rebase 23-fft-channelizer
on to main
and basically want 23-fft-channelizer
to overwrite what's in main
since it 23-fft-channelizer
is the most up to date and working branch.
I would however want to keep the history of main
in case I ever need to refer back to it.
REMOTE REPO
https://github/bigalnz/test_fft/blob/main/src/kiwitracker/sample_processor.py
ENVIROMENT
I am using VSCode for my IDE and on a Windows OS.
STEPS SO FAR
- Made a backup copy of branch
23-fft-channelizer
in case anything goes wrong. - Sync'd both
main
and23-fft-channelizer
with remote repo. (git pull
on each main/feature - response was up to date on both) - Made sure both are saved to local disk.
- git rebase main
Now this is where the issues start. I get a conflict with the option to resolve in the VSCode IDE about which code to accept. It looks like this:
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)
ISSUE
Neither of those lines can I find in the current local copy of that file, but it does exist on the repo at https://github/bigalnz/test_fft/blob/main/src/kiwitracker/sample_processor.py#L240
Q: So what is going on - why is that line not on my local copy and how can I resolve this?
Q: Are the two code snippets above diff's between two versions of main
?
2 Answers
Reset to default 1Just merge main
into the other branch using -s ours
so that the operation actually does not affect the branch content as you have it.
git checkout x
git merge -s ours main -m "keeeping the history of main"
gig checkout main
git merge x # this should do a fast-forward
Q: Are the two code snippets above diff's between two versions of main ?
No. The conflict indicates both main and 23-fft-channelizer changed the same piece of code. From the conflict we see that 23-fft-channelizer changed it in 1f893dc Make project runnable on Linux
Q: So what is going on - why is that line not on my local copy and how can I resolve this?
From your git log
we can see that main has a change in commit 269ea00 which is likely causing the conflict.
- 269ea00 Updated matched filter ln 240 to samples = signal.convolve(samples, [1]*189, 'same')/189
You can use git log -p 269ea00
to see the content of that change and git log -p 1f893dc
to see the change in 23-fft-channelizer. This will give you information about whether you want to keep it.
If you wish to see all the commits which are in main but not in 23-fft-channelizer, run git log 23-fft-channelizer..main
. This will allow you to better decide if you want to throw out main's history. See gitrevisions - Specifying Ranges.
As you can see from your git log
, Git history is connections between commits. But branches are just labels pointing at a particular commit. If you truly want to replace main with the history of 23-fft-channelizer simply rename the branches.
git branch -m main old-main
git branch -m 23-fft-channelizer main
Now main is what used to be 23-fft-channelizer, and old-main is what used to be main.
本文标签: Git Rebase Feature Branch to MainConflictStack Overflow
版权声明:本文标题:Git Rebase Feature Branch to Main - Conflict - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742058822a2418459.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
git log --decorate --graph --oneline --all
will show the true history of your repository and if there's any important changes in main. Clearly there are changes in main. – Schwern Commented Jan 19 at 21:15