8

When I do git status, I see some files having local changes (seems to be indentation changes).

And when I do git stash, it doesn't remove those files from the queue. It blocks my auto pull script from fetching from remote git.

$ git stash
Saved working directory and index state WIP on develop: 05c60a5 Merge remote-tracking branch 'origin/develop' into develop
HEAD is now at 05c60a5 Merge remote-tracking branch 'origin/develop' into develop

$ git stash
On branch develop 
Your branch and 'origin/develop' have diverged and have 23 and 127 different commit(s) each, respectively.

Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) 

    modified:   config/buznames/businessname_map.
    modified:   public/css/_lib/dropdown.less
    modified:   public/css/_lib/secureBadge.less
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
sonicMandelBrot
  • 91
  • 1
  • 1
  • 5
  • 1
    Run `git diff` to see what’s different. Is it indentation or line endings? – poke Jul 10 '15 at 06:50
  • It looks like a formatting change. The content wholly removed and added again. – sonicMandelBrot Jul 10 '15 at 06:56
  • `git checkout -- file ` also didn't seem to work for those files. – sonicMandelBrot Jul 10 '15 at 06:58
  • Do you have a `.gitattributes` file somewhere? Also, what does `git config core.autocrlf` say? – poke Jul 10 '15 at 07:06
  • @poke doing a `git config core.autocrlf ` says "true" – sonicMandelBrot Jul 10 '15 at 07:10
  • 1
    Okay, that’s what I thought. You should set it to false. See also the following questions: [Why should I use core.autocrlf=true in Git?](http://stackoverflow.com/questions/2825428/why-should-i-use-core-autocrlf-true-in-git), [How to remove unstaged changes in git?](http://stackoverflow.com/questions/4221082/how-to-remove-unstaged-changes-newline-characters-difference-in-git), and [Unstaged changes left after git --reset hard](http://stackoverflow.com/questions/11383094/unstaged-changes-left-after-git-reset-hard). – poke Jul 10 '15 at 07:16
  • Thank you poke . that did the magic :) – sonicMandelBrot Jul 10 '15 at 11:04
  • You may have fallen victim to the mysterious filemod glitch, try a `git config core.filemode false` – reim May 29 '18 at 22:36

1 Answers1

6

git stash will remove any uncommitted changes but not your local (unpushed) commits.

I believe your local branch has diverged and you're having merge conflicts when you're trying to pull. You will have to resolve these conflicts before being able to continue with the pull request.

If you're trying to remove all local commits in your develop branch with respect to the remote branch you can do something like:

$ git checkout develop
$ git fetch origin develop
# Reset develop branch back to origin/develop
$ git reset --hard origin/develop

NOTE: THIS WILL DELETE/DISCARD ALL YOUR LOCAL COMMITS. YOU WILL NOT BE ABLE TO RESTORE THEM

umläute
  • 28,885
  • 9
  • 68
  • 122
dmlittle
  • 964
  • 6
  • 15