How to discard staged changes in Git -


My question relates to:. I use multiple work directories from the same Git repository. Usually, I have work in different branches in each work directory, but it may be that I work in a branch from a working directory, while the other is working Directory is the checkout of the same branch. When this happens, the other working directory changes which are behind the committal I made. Now my question comes ...

Without leaving non-structured modifications, one step How can the changes be removed?

Edit: I do not want to be bothered with phased changes (such as git reset ), but I would like to completely stop the phased changes.

To discard the pointer without touching the work tree, you can:

  git reset  

This is what it does. This is equivalent to your own answer, "Using the git command only" the end effect always likes to mess about the results of git diff HEAD , everything runs back into the highest commitment, and then The original work tree to recreate the head to re-apply that code.

But it seems that you want to throw away the changes from the index, such as those omitted changes are actually subtracted from your work. In that case, what I does that interactive rebase will be used to share the changes:

  git commit # index to earn a GIT commit- a # The rest of the changes are GIT Rebase - Interactive HEAD ^^ # Ribbase Top Two is built on the same branch  

In the editor window that comes, I will just delete the comma which will allow incoming unwanted changes Catching from unwanted index, and then save and release, int Aktiv give comfort Ribas. Merge may be a collision, which must be resolved, because the desired changes that were previously unstable may have been dependent on undesirable changes.

Finally, I will have a single commitment, in which there will be changes that were already unstable, and the unwanted changes have gone, at that point, I can get rid of that commitment, in the unstable change Change:

  Reset git HEAD ^  

Or just keep committing and hacking more and working with it "git Commit --amend to add it and update its message.

Whatever Esc - Interactive does (and in fact, it resets non-interactive) can be done with cherry-pick command, but it provides a convenient "workflow automation" .

Redo Commit, Delete Commit, Together Multiple Commitments in One, Rewrite committed messages (except for the highest patches) and rewriting that type of thing, this Good to know how interactive The Rebase is used.

The idea is to change all of your changes into different commitments, then work with bitter foo and eventually "de-commit" something, if necessary Then

To do complex things, GIT is better at working with commute than unstable change or index, which are like temporary areas; So you want to take your work out and earn in the first place. In fact, if you have not made changes or made changes, then you prevent you from doing various useful things.

One of the reasons for improving your work is that it is easy to lose working copy in GIT or index forever. are not working copy and index objects and therefore they are not recoverable from referrals. Type the wrong command which wipes both of these or both, and they have gone for good

< / P>


Comments