Untracked files between branches in Git

前端 未结 3 490
日久生厌
日久生厌 2021-01-30 11:03

I\'ve been searching around here for to look for an answer and it seems I may just be making incorrect assumptions on how git branches are supposed to work.

I have my

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 11:27

    It sounds like you created the branch with git branch profiles, but didn't switch to it, so you stayed in master, and it got the file changes when you did a commit.

    After creating the branch, you need to explicitly switch to it with git checkout (just create new branch on-the-fly and switch to it in one step using git checkout -b ).

    If you have changes you don't want to lose (or commit to the current branch), but instead put into the other branch, do:

    git add -A
    git stash
    git checkout 
    git stash pop
    

    More info on git stash is available from git-scm.com

提交回复
热议问题