How to return the git add --all command

Asked

Viewed 510 times

2

I ended up using this command improperly, and added many files that should not, wanted to return the previous state, command git reset HEAD <file> returns only one file, and as there are many it is impossible to use it. I added the name of the directory to the file .gitignore, but when the command was running git status was listed all the files in the phase of being committed, I did not commit, because I believe commit and then do the push, these files will be loaded (maybe it’s wrong). I saw in a link of the OS-pt that the command git reset HEAD * would return all changes to the state untracked, the files that went back to that state was exactly the file .gitignore and not the files I had previously added. How do I go back?

  • 2

    Just try to git reset.

  • 2

    Use git reset . with space and period after reset

  • Related: https://answall.com/q/325951/112052

2 answers

1

We have an example of this in git manual online

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

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

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

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

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

(The pseudo-translation of the link is not 100% faithful, because I tried to explain more with my own words)

  • Then in case it is necessary to just add to the stage and commitar both?

  • Afterward, git add <arquivos alterados>, git commit and finally git push so that changes are not local

0

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

P.S.: hash concerning the commit

Browser other questions tagged

You are not signed in. Login or sign up in order to post.