Skip to content

How to switch to another branch #22552

Answered by Wabri
tomyang03 asked this question in New to GitHub
Discussion options

You must be logged in to vote

If you are in branch2 you need to push to branch2 and not in master, with git push origin master you push your local master to origin. If the changes are made in branch2 you had to push to branch2:

git push origin branch2

then you can switch to master with:

git checkout master

In order:

  1. The first command you run is:

    git branch -a

That show the list both remote-tracking branches and local branches.

  1. You tried switch to local master using checkout, but there are changes in the branch2 so the checkout command was aborted.

  2. You added and committed the changes in branch2 using:

    git add .
    git commit -m “10th commit”

  3. Now the error , you pushed to origin master the changes, but there ar…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants