nvie / gitflow

Git extensions to provide high-level repository operations for Vincent Driessen's branching model.
http://nvie.com/posts/a-successful-git-branching-model/
Other
26.6k stars 2.66k forks source link

git init flow says working tree contains unstaged changes, but it's not true #6401

Closed TheJoeSchr closed 6 years ago

TheJoeSchr commented 6 years ago

Hi,

I can't git init flow in an existing repo, what can I do to fix this?

There are no unstaged changes, it's a lie, I already did this:

% git flow init
Fatal: Working tree contains unstaged changes. Aborting.
% git reset --hard
HEAD is now at 5e30792 
% gs
On branch feature-xyz
Your branch is ahead of 'origin/feature-xyz' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
% git flow init
Fatal: Working tree contains unstaged changes. Aborting.
brodriro commented 6 years ago

try : git commit -m "TAG" git push --all git flow init -d

TheJoeSchr commented 6 years ago

Thx, but sadly still the same results:

% git flow init -d
Fatal: Working tree contains unstaged changes. Aborting.
TheJoeSchr commented 6 years ago

Even with force:

% git flow init -f -d
Fatal: Working tree contains unstaged changes. Aborting.
brodriro commented 6 years ago

check #81

TheJoeSchr commented 6 years ago

thx, I already tried the suggestion in #81 before, and just tried them again, still no luck.

% git reset --hard origin/master
HEAD is now at 5e30792 
% git flow init -f
Fatal: Working tree contains unstaged changes. Aborting.
% gs
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
% git status
git add .
git status
git commit -m 'Commit typechanges'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
% git flow init -f
Fatal: Working tree contains unstaged changes. Aborting.
TheJoeSchr commented 6 years ago

I finally got it to work, by making a new dir, repo and then pulling the remote git in. Maybe the problem is that I'm also using git-crypt?

For example

mkdir project-with-flow
cd project-with-flow
git init
git flow init
git remote add origin example.com/project.git
git pull
# do this for every branch
git branch --set-upstream-to=origin/master master 
brodriro commented 6 years ago

Nice, Now it's ok?

TheJoeSchr commented 6 years ago

Yes, now everything seems to work. I only had it once again, with a git flow feature command, but I can't remember which. Maybe publish. I just did git push -u --all then.

brodriro commented 6 years ago

Close this issue :D

TheJoeSchr commented 6 years ago

Ah damn, I just got it again, with git flow feature finish, I now suspect it has something to do with using git crypt. I will close this issue

montao commented 6 years ago

I have the same problem. I'm just trying to do very simple and everyday tasks, then I added git and git-flow and now I can't use anything.

jerryhu commented 5 years ago

I got same issue and I tried below command which worked for me

git reset --hard

Refer: https://stackoverflow.com/questions/28251527/initializing-git-flow-in-existing-repository

gongAll commented 4 years ago

I'm a bit too late, but what I usually do is something along the lines of: git stash && git flow <command> && git stash pop

Hope this helps anyone in the future :)

gitressa commented 4 years ago

Thanks @gongAll, that worked perfectly! A lot easier than resetting, and recreating the changes. To spell it out, these commands worked for me, after getting Fatal: Working tree contains unstaged changes. Aborting.:

git stash
git flow init
git flow feature start my-new-flow-feature-branch 
git stash pop
marmelin commented 5 months ago

Hi, there is always one where it did not work it out :)

❯ git reset --hard
HEAD ist jetzt bei b09828d9 update version to 1.13.7-SNAPSHOT
❯ git -c core.quotepath=false -c log.showSignature=false flow init
Fatal: Working tree contains unstaged changes. Aborting.
❯ git stash
Keine lokalen Änderungen zum Speichern
❯ git flow init
Fatal: Working tree contains unstaged changes. Aborting.

I am also using git-crypt, but that does not show any problems. No stashes nowhere.