I have a local repository with 3 branches - main, major-test, recovery - and a remote repository with equivalent branches - main, major-test, recovery. My current working branch is major-test. During an attempt to revert a bad commit, I used a series of git reset and git revert. In the end, I realised that I made a mess and to fix it I moved the 'myfile.java' file with the correct changes to a different branch recovery. Now, I wanted to retrieve the 'myfile.java' file saved in the recovery branch and update the current branch, major-test, with those changes. So, I used the following command:
git checkout recovery -- src/myfile.java
It worked as expected and the current working folder src contains the 'myfile.java' file with the changes I wanted. However, what I did not expect was that also my remote repository got updated at the same time. Usually, when I want that some changes on my local repository are reflected on the remote (called origin) I use this command:
git push -u origin major_test:major_test
This time it was not necessary and I don't understand why.Indeed, I logged in into the webpage of my github repository and noticed that the file there was the one with the updated version. It also means that when I check the status with the 'git status' command I get this:
On branch major_test
Your branch is up to date with 'origin/major_test'.
nothing to commit, working tree clean
Is it possible that during the previous attempt to fix a bad commit I accidentally pushed the changes into the remote repository but those changes were not visible because they were not synchronised with the local repo?