Whenever I am trying to run:
git checkout main
I am getting an error:
error: The following untracked working tree files would be overwritten by checkout:
README.md
Please move or remove them before you switch branches.
Aborting
I have tried doing the following steps:
-
git rm --cached README.md git checkout main
Didn't work.
-
git add -all git commit -m "initial commit" git checkout main
Still the same output.
CodePudding user response:
If you don't want to keep README.md change:
git add README.md
git reset HEAD --hard
git checkout main
If you want to keep README.md change:
git add README.md
git commit -m "Your commit message"
git checkout main
or you want edit it at main branch later:
git add README.md
git stash
git checkout main
git stash pop
CodePudding user response:
Try: git checkout -f master
Also check branch name. The default branch name in Git is master.