First created a txt file under the master, then git checkout -b dev
created a new branch, changed the content of the txt file under the dev branch, and the result was directly returned to the master branch successfully, and the content was also updated. , what is the problem and how should it be corrected?
How to modify it so that it will be out of sync?
Did you switch back to master directly without committing under dev?
In this case, your changes are still in the cache and do not belong to any branch. So after you switch to master, you find that the content has been updated.
The normal process is to commit to the dev branch first, and then merge to the master.
So you should now checkout to dev again, and then perform the above commit and merge operations.
In fact, if your master also changes the same file, git will prompt you that you cannot switch from dev to master unless you commit first or stash the cache.