Open QQH0828 opened 1 year ago
@QQH0828 Just to get more details, are you also using branches while doing these changes?
Probably unlikely, but I've encountered similar issues in the past when I use git on a directory that is being synced by some application (e.g. onedrive, google drive).
2 possible factors to consider other than hingen's response:
git merge master
from the master from your own fork.git checkout -b new-branch
instead of master? Not sure if that could result in unintended consequences but making changes on the original branch can cause changes to spill over to newer branch.Also, did you try to call git log
to see if your previous commits have disappeared from your local when you encounter this problem?
Another way is to check your PR and see if the previous commits are registering and if your later commits have somehow deleted your work too.
@QQH0828 Just to get more details, are you also using branches while doing these changes?
Hi, prof. Thank you for reading. Yes, I was using branches while doing these changes. Basically, I was doing the changes in the same branches and did not switch to other branches.
Probably unlikely, but I've encountered similar issues in the past when I use git on a directory that is being synced by some application (e.g. onedrive, google drive).
I also have no idea about it. And I just countered this issue again.
2 possible factors to consider other than hingen's response:
- Did you possibly leave out your code when doing merge conflicts? It can be easy to miss clicking the ✔️ button instead of the ❌ button when on Intellij if you do merges by using
git merge master
from the master from your own fork.- Did you branch out from another branch when calling
git checkout -b new-branch
instead of master? Not sure if that could result in unintended consequences but making changes on the original branch can cause changes to spill over to newer branch.Also, did you try to call
git log
to see if your previous commits have disappeared from your local when you encounter this problem?Another way is to check your PR and see if the previous commits are registering and if your later commits have somehow deleted your work too.
Thanks for giving the suggestions. I am checking the previous result in the source tree and it looks fine. I think I did not branch out from another branch, since I always create a new branch from master only.
Does it perhaps occur when you're doing a git merge
?
For example, your teammate updated the master
branch so you merge the updated master
branch into your feature-branch
. However, your teammate made some changes which overwrites your changes. If your feature-branch
is very far behind on commits from the master
branch, sometimes, git doesn't detect such changes as merge conflicts.
Does it perhaps occur when you're doing a
git merge
?For example, your teammate updated the
master
branch so you merge the updatedmaster
branch into yourfeature-branch
. However, your teammate made some changes which overwrites your changes. If yourfeature-branch
is very far behind on commits from themaster
branch, sometimes, git doesn't detect such changes as merge conflicts.
I have this issue even my teammates do not touch the master st all.
@QQH0828 Seems very specific to you Could be either you are doing something incorrectly or something wrong with your git/Sourcetree setup. But hard to decide without more details. Perhaps take screenshots are relevant points, or switch to CLI and share all the git commands you typed in your terminal so that others can see what exact operations you did.
I changed some parts of the codes, and I committed them, it will be okay. But if I change something else and try to commit again, then some of the changes in the previous commit will show on the source tree also, and it somehow converts back to the first version.
For example, if I change a method name from
addPerson
toaddMoney
in thePerson
class, and I commit it, it will reflect in the codes. Then I change something else, maybe UG, and then I want to commit it. I found that sometimes the staged files will also havePerson
class, and it shows the changes fromaddMoney
toaddPerson
.If I did not check properly, these changes are gone, and I need to redo them again. I realized this problem because I think I countered this issue several times. But I still cannot figure out why.