How to rewind the git command add --all

2

I ended up using this command unduly, and added many files that I should not, wanted to go back to the previous state, the command git reset HEAD <file> returns only one file, and how many are unfeasible to use it. I added the directory name to the .gitignore file, but when I run the git status command, all the files are listed in the commit phase, I did not commit because I believe I commit and then do push , those files will be loaded (maybe it's wrong). I saw in an SO-pt link that the git reset HEAD * command would return all changes to the untracked state, the files that returned to that state were exactly the .gitignore file and not the files that I had previously added. How do I get back?

    
asked by anonymous 06.12.2018 / 00:58

2 answers

1

We have an example of this in git online manual

$ edit                                     
$ git add frotz.c filfre.c                 (1)
$ mailx                                    (2)
$ git reset                                (3)
$ git pull git://info.example.com/ nitfol  (4)

The example is as follows: you are working on something and decide to add files that you are sure are good. (1)

There, someone makes an important change, which, although not directly part of your work, is in the same files. (2)

However, as you have already added something, your index is already different, and pulling would cause conflict. To solve this, the best way is to reset before making a pull of the changes that are in the base. The add is undone, but the changes are retained. (3)

So when you pull, you can merge (if it's not automatic). Then you continue to synchronize with the base, without losing your changes. (4)

(The pseudo-translation of the link is not 100% accurate, as I tried to explain more with my words myself)

    
11.12.2018 / 16:55
0

I typed the command git log and copied the hash of a previous , then I used the command git reset --hard hash .

Q: hash for commit     

06.12.2018 / 06:12