So I asked a question yesterday about rebasing in git and got some good answers on what to do. However When I proceeded, I ran into issues that I dont understand 1 bit.
To give a quick overview:
I branched out (Branch2
) from another branch - Branch1
. Branch1
is remote and had a number of commits AFTER I branched from it. All those commits are not squashed. Meanwhile I went about making changes in Branch2
. Now Im done with my changes and have to rebase Branch2
on top of Branch1
.
When I do git status
in Branch2
it lists all the files that I have changed (which seems right). However when I do a git checkout Branch1
and the git status
it lists the same files again. I dont understand this, I was under the impression that each branch is like a localized environment and does not show changes to other branches.
Another thing that has my head spinning is that - Branch1
has moved forward since I branched out from it. Before rebasing I wanted to update my local copy of Branch1
so that my changes in Branch2
get rebased on top of the the most recent commits of Branch1
so I did git checkout Branch1
and git pull
. However I got :
error: Your local changes to the following files would be overwritten by merge:
file...
Please, commit your changes or stash them before you can merge.
Aborting
I dont understand:
- Why are changes done in
branch2
showing ingit status
ofBranch1
? - If I commit and push my changes on
Branch1
, thengit pull
, where will my commit be placed as all the previous commits including the commit where I had branched of of inBranch1
have been squashed.