How to switch to another branch #22552
-
I am using git checkout master, but when i do git branch -a , it is still pointing to branch2. PS C:\Node\projects\n-5-10-workflow-test> git branch -a |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
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:
then you can switch to master with:
In order:
That show the list both remote-tracking branches and local branches.
Gived the output:
And this is right, because your precedent commit was made on branch2. You need to push branch2 to origin, with this:
After push to origin branch2 you can run:
and it will be succesfull. Hope to solve your problems. -Gabriele- |
Beta Was this translation helpful? Give feedback.
-
Exactly what @wabri says; your checkout gets aborted because Git could then possible destroy files. See this line:
|
Beta Was this translation helpful? Give feedback.
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:
then you can switch to master with:
In order:
The first command you run is:
git branch -a
That show the list both remote-tracking branches and local branches.
You tried switch to local master using checkout, but there are changes in the branch2 so the checkout command was aborted.
You added and committed the changes in branch2 using:
git add .
git commit -m “10th commit”
Now the error , you pushed to origin master the changes, but there ar…