You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flacial edited this page Jul 19, 2022
·
3 revisions
About: This page list solutions for most issues students may encounter
Checked out from a branch other than master
Example of when it might happen:
We're in p1 branch, and it has 2 uncommitted changes
We then create a new branch with git checkout p2 or git switch -c p2
Why is it an issue?
Checking out from a branch other than master might cause possible issues like submitting multiple unintended files caused by the changes from the previous branch (p1) being added to the new branch (p2).
How to fix it?
Run git stash in the branch you're on to store the changes
Run git switch master to go back to the master branch
Run git branch -D <WRONG_BRANCH_NAME> to delete the wrong branch (in the example, it's p2)
-D means Delete
Run git switch -c <BRANCH_NAME> to create the branch again
-c means create
Run git stash pop to restore your changes
What should I do so it won't happen again?
You'll have to checkout from master whenever you try to solve a new challenge
Run git branch and make sure the star is next to master
If it's not, run git switch master to switch to master