I have been struggling with git rebase and not sure how it works. So, what I did is following steps:
git checkout main
git pull origin main
git checkout my-branch
git rebase origin/main
Then I got some message in console saying I need to resolve the conflicts before continuing. The problem is when I open the "red" file, none of the current change or incoming change is the code that I just modified before I rebase.
<<<<<<< HEAD
.MuiSwitch-root .MuiSwitch-switchBase.Mui-checked {
=======
/* .MuiSwitch-root .MuiSwitch-switchBase.Mui-checked {
>>>>>>> cbfe089 (built skeleton for Settings Page)
color: var(--primary-clr) !important;
}
.MuiSwitch-switchBase.Mui-checked .MuiSwitch-track {
background-color: black !important;
opacity: 1 !important;
background: linear-gradient(#f4f4f4, #e9e9e9) !important;
<<<<<<< HEAD
}
=======
} */
>>>>>>> cbfe089 (built skeleton for Settings Page)
I made changes for the whole file and none of these are my current code. Plus, I noticed some of the files I added are also nowhere to be found. I have no idea what is happening.
I don't think I can help you with the conflicts themselves, but I can explain what rebase does and it might help you deal with it better next time. Let's say the state of your git history is this:
a <- b <- c <- d <- e <- f <- g
^main ^my-branch (HEAD)
You've been working on your branch so you're ahead of main by a few commits. Your recent work is in commits e, f, and g. Then you checkout main, setting HEAD to it.
a <- b <- c <- d <- e <- f <- g
^main (HEAD) ^my-branch
You pull origin/main. Turns out someone else has pushed updates, commits h, i and j.
a <- b <- c <- d <- e <- f <- g
^ ^my-branch
|
h <- i <- j
^main (HEAD)
When you checked out my-branch and ran git rebase origin/main
, it took commits e, f, and g and stuck them at the end of j:
a <- b <- c <- d
^
|
h <- i <- j <- e <- f <- g
^main ^my-branch (HEAD)
It does this by applying e/f/g one at a time on top of what's at j. The problem is that if h/i/j modified the same files as e/f/g, then you have to manually resolve the conflicts. That's why you see code that's unfamiliar to you. Because you didn't write h/i/j, but it can still show up in the conflicts.
I unfortunately can't help with the missing files, that sounds like while resolving the conflicts you might have accidentally deleted your own changes (the stuff in e/f/g).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.