Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doing a git stash doesn't remove changes in git local [duplicate]

Tags:

git

git-stash

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
like image 549
sonicMandelBrot Avatar asked Jul 10 '15 06:07

sonicMandelBrot


People also ask

Does git stash delete changes?

Re-applying your stashed changes Popping your stash removes the changes from your stash and reapplies them to your working copy. This is useful if you want to apply the same stashed changes to multiple branches.

How do I get rid of local changes?

There are two Git commands a developer must use in order to discard all local changes in Git, remove all uncommited changes and revert their Git working tree back to the state it was in when the last commit took place. The commands to discard all local changes in Git are: git reset –hard. git clean -fxd.

What happens if you git stash twice?

If you made two stashes, then just call git stash pop twice. As opposed to git stash apply , pop applies and removes the latest stash. You can also reference a specific stash, e.g.


1 Answers

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

like image 183
dmlittle Avatar answered Sep 18 '22 13:09

dmlittle