Home > Enterprise >  modify local branch base on origin/master will affect local master branch?
modify local branch base on origin/master will affect local master branch?

Time:08-19

I have created a branch named test based on the origin/master branch, then I made some changes to the test branch, I found out the same modification also appeared on the local master branch, is it normal?

Or What should I do to avoid this situation happen again,should I create a branch base on another remote branch?

Thanks for your answer

CodePudding user response:

My git command is git checkout -b test origin/master

Do not use the old and confusing git checkout command, but, since Git 2.23 (Q3 2019) the git switch command.

Any modified files in the index (git add) would still be there when switching branch. If you don't want that:

  • either git switch to your previous branch (git switch -) and commit there.
  • or git stash those changes.
  • Related