3

I have the following branches master -> php-merge-2016, master -> css-merge-2016 and master -> css-merge-2016 -> b4-selector-removal. To start with I need to merge b4-selector-removal-new to php-merge-2016.

Currently I am working on branch b4-selector-removal and all changes are committed and pushed to remove repository and git status shows "working directory is clean"

So to merge b4-selector-removal-new to php-merge-2016 branches I first tried to be on my php-merge-2016 branch. When I switch to php-merge-2016 using git checkout php-merge-2016 it gets checked out without a problem and here again git status shows working directory is clean as I haven't made any changes yet.

Just to do a bit of experiment I tried to switch back to b4-selector-removal-new branch without doing anything. But git is now saying:

Your local changes to the following files would be overwritten by checkout:
sites/all/themes/base/css/info-grid.css
sites/all/themes/base/css/info-grid.css.map
sites/all/themes/desktop/css/print.css
sites/all/themes/desktop/css/print.css.map
sites/all/themes/mobile/css/ifa-upload.css
sites/all/themes/mobile/css/ifa-upload.css.map
Please, commit your changes or stash them before you can switch branches.
Aborting

Interesting thing is the files shown above are the ones which I committed and pushed last before switching back and forth between two mentioned branches.

Why I am getting this error? What is the work around. I did not use git checkout -f because I am not sure what it would do. I am not yet very much familiar with git yet so worrying using anything which forces something.

I had seen in another post that I could have used git reset --hard before checking out to another branch. what this do? Would this be harmless if I use this in my case? Will it resolve the issue?

Please help!

Subrata Sarkar
  • 2,975
  • 6
  • 45
  • 85

1 Answers1

0

Create backup. Try git reset --hard

If that did not help, read this Git - Difference Between 'assume-unchanged' and 'skip-worktree'

Probably you manually set assume-unchanged or skip-worktree for you files. In that case, changes are not affected in git status.

Eugene Lisitsky
  • 12,113
  • 5
  • 38
  • 59
hemn
  • 365
  • 2
  • 9