Try to get back to your branch, commit your changes, then checkout the master again. Since your changes were never committed, you'd lose them. If you really want to discard the local changes, you have to force the checkout with -f. That is why your last status still show your local changes, although you are on master. git did change the HEAD, but did not overwrite your local files. , which means that your working files are not clean. The result of your checkout master is: M testing ![]() Upon changing branch, git does not overwrite your local changes. Since the changes are only local, git does not want you to lose them too easily. Edit to explain the result of checkout master -Īre you confused because checkout master does not discard your changes? It just creates the branch from the current HEAD and sets the HEAD there. Before Update 2020 / Git 2.23ĭoes not touch your local changes. Starting with this version of Git, replace the git checkout command below with: git switch -c Git 2.23 adds the new switch subcommand, in an attempt to clear some of the confusion caused by the overloaded usage of checkout (switching branches, restoring files, detaching HEAD, etc.) Saved working directory and index state WIP on master: 4402b8c testingĭropped (db1b9a3391a82d86c9fdd26dab095ba9b820e35b)ĭo you know if there is any way of accomplishing this? No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) ![]() Nothing to commit (working directory clean) I supposed git stash & git stash branch new_branch would simply accomplish that but this is what I get: ~/test $ git status This always happens to me and I have no idea how to switch to another branch and take all these uncommited changes with me leaving the master branch clean. After a few minutes I realize it was not so simple and it should have been better to work into a new branch. Context: I'm working on master adding a simple feature.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |