#Interactive Rebase Help
1 messages · Page 1 of 1 (latest)
<@&987246964494204979> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
I want to only take certain changes from Add logs for IgClient and discard the others
I wish to keep all changes from the commits after that
I am guessing interactive rebase is the solution, but I was not able to start one in gitkraken as it did not give me the option when i right-clicked on main
when i started one in terminal, i could not find all the commit names which i had to mark as p, r or e so I aborted the rebase
if u want to modify a commit, its a bit more difficult. but doable
check out the troublesome commit first
first of all, create a safety branch
on the latest commit
so Changes
so the first thing u should do now is to create a branch
main_backup or sth
then, right click the troublesome branch and click "reset hard to this commit"
ur now "on that commit"
next, right click the commit right before it. so Add sl4j framework and click "reset mixed to this commit"
mixed, not hard, not soft
this will delete the commit, but u keep all the changes as unstaged change now
u can now edit the code and craft ur new commit
once done, commit it as usual
then, u have to get back the ~6 other commits that were above it previously
therefore, do cherry-pick
cherry-pick each of them
temp is my safety branch, all my actual work was happening on main
make a safety of main though
otherwise, when u do the reset, ur extra commits are gone
yes. but those commits are local to ur machine only, arent they
so if u do a mistake, they are gone forever
we need them for the cherry picking
no i think they are pushed
ill make one just in case still
alternatively, u can do an interactive rebase per console
cause the console stops after each one
and gives u the chance to edit the code
the gitkraken UI doesnt
yeah but i dont know vim too well
so i made the backup branch
my temp is on the commit before the bad commit
should i checkout the bad commit then?
from temp?
do u want to do it with console-interactive-rebase or the way i said earlier?
i prefer gitkraken ui
u made a backup of this branch/commit?
https://i.imgur.com/wHYZ1k1.png
yes
okay, then go on the branch u want to change, i guess thats that main branch
then right click the troublesome commit and reset-hard on it
so this guy here
this will delete all commits above (for this branch - but u have the backup)
main branch is also on Changes only btw
it will still work?
then reset it hard to the lgCLient commit
this will delete all newer commits from it
permanently
done
which is why we made a backup
now reset-mixed to the commit before it
the sl4j framework commit
this will delete the commit, but keep the code changes (unstaged)
yup now its unstaged
u should now have the code changes on ur right, as if u just coded them fresh
as a WIP
now change the code
once done, commit
then cherry pick all commits u want
(right click > cherry pick)
should i just discard uneccessary hunks?
u have now the Add logs for lgClient changes unstaged
u can now freely modify them
with ur intellij or whatever
ah ok i got it
once ur satisfied, commit them as usual
then u have to cherry pick all the newer commits on top
can i squash them or something?
if thats what u want
or u squash afterwards
with interactive rebase
cause thats easy with the ui
oh i got a merge conflict
its cuz of this one line
i want to keep everything from the left, except for the one line where i log it
that i want to get from the right
but when i try to add that line it puts it at the end of the chunk, not where it originally was
is this possible to do in gitkraken?
merge conflict from one of the cherry pick commits?
yeah
i had 2 conflicts(same file), i fixed one of them but the second one i had that problem
dont u have a third window below those where u can manually write the target file?
i need prenium to edit in that window 😄
lol what
dunno, i never use the built-in merge. i always use p4merge and tell my gitkraken to use that instead
probably. worst case, u just click anything and then reset-mixed that commit to adjust it
i resolved the conflict and then added the missing line in intellij
yeah it worked looks like
everything is cherry picked
now ill merge to main?
if ur branch looks the way u want, u can now push it wherever u want
either by resetting the other branch to it (hard reset)
or by force pushing ur branch on them
or if the history is compatible, normal push
this thing is also normal btw right?
yes, the history is incompatible since u changed a commit content
needs a force push now
it says im in a detached head state
do u still have a rebase going on or something
i accidently checked out a commit instead of cherry picking it, but i immediately checked out my to my previous state, maybe thats what caused it
detached head means there is still some operation going on. so ur in a special state. for example during rebase or a merge conflict