I had a bunch of files in the directory in git that weren't tracked. I made the mistake of doing git add .
then committing and pushing the changes. How can I get back to where the files that were untracked before that commit are untracked again, but still in the directory (git reset --hard
deleted all the files, not good for me, instead of untracking them again). I have my many files in different locations that need to be untracked, so git reset <FILE>
won't work for me.
答案 0 :(得分:1)
$ git commit -m "Something terribly misguided" (1)
$ git reset HEAD~ (2)
<< edit files as necessary >> (3)
$ git add ... (4)
$ git commit -c ORIG_HEAD
答案 1 :(得分:1)
First, you should revert the last commit and return all the files back to the staging area by :
git reset --soft HEAD~1
This will not delete any files and it's safe.
Then, you can remove all the files that are added to the staging area by :
git reset
Now if you run the git status
, you can see that all the files are unstaged.
You can then git add
the only files you want.