Git moves files/folders with when checking other b

2019-02-15 22:13发布

  1. I am currently on the "master" branch.
  2. I created a new branch (from the master branch) to work on a new "users" feature. that's why i called this new branch "users".
  3. I had to stop my work and go back to the master branch.
  4. I stashed "users" for all the files i was working on - so basically my status is empty.
  5. Now I can safely checkout back to the "master" branch.
  6. "master" branch shows me one of my folders (node_modules) as if I added it and "ready to add and commit" - as if it was dragged from the previous repository.

PROBLEM:

I keep getting the changes from the previews branch ("users") in my master branch.

If I delete these files - I would have no problem to work on my master branch - but when returning to the "users" branch - these files are gone (because i deleted them in the master branch)

It seems like I somehow have a "static" folder that is dragged to every branch

What might be the problem with my git ?

The folder I am referring to is the node_modules folder. I'm not sure I remember what happened to it, I added it in the beggining, then deleted it. made sure it's not displayed in the repo in "bitbucket". then had git update-index --assume-unchanged $(git ls-files | tr '\n' ' ') run on the whole folder. It just keep poping up in every branch i move to.

WHAT I EXPECT TO HAPPEN:

  1. I am currently on the "master" branch.
  2. I created a new branch (from the master branch).
  3. I had to stop my work and go back to the master branch.
  4. I stashed "users".
  5. Now I can safely checkout back to the "master" branch.
  6. "master" branch is empty to work on - some files "disappeared" since they don't exist on this branch).

1条回答
在下西门庆
2楼-- · 2019-02-15 22:42

If git stash is misbehaving for any reason, another approach is:

When you need to stop, add everything and commit in your current branch, then switch back to master.

When you resume your work on user, you can cancel the last commit:

git reset @~

Your changes and work in progress will be there, ready to be (once again) added and committed.

查看更多
登录 后发表回答