Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are three basic ways to do this depending on what you have done with the changes to the file A. If you have not yet added the changes to the index or committed them, then you just want to use the checkout command - this will change the state of the working copy to match the repository:</p> <pre><code>git checkout A </code></pre> <p>If you added it to the index already, use reset:</p> <pre><code>git reset A </code></pre> <p>If you had committed it, then you use the revert command:</p> <pre><code># the -n means, do not commit the revert yet git revert -n &lt;sha1&gt; # now make sure we are just going to commit the revert to A git reset B git commit </code></pre> <p>If on the other hand, you had committed it, but the commit involved rather a lot of files that you do not also want to revert, then the above method might involve a lot of "reset B" commands. In this case, you might like to use this method:</p> <pre><code># revert, but do not commit yet git revert -n &lt;sha1&gt; # clean all the changes from the index git reset # now just add A git add A git commit </code></pre> <p>Another method again, requires the use of the rebase -i command. This one can be useful if you have more than one commit to edit:</p> <pre><code># use rebase -i to cherry pick the commit you want to edit # specify the sha1 of the commit before the one you want to edit # you get an editor with a file and a bunch of lines starting with "pick" # change the one(s) you want to edit to "edit" and then save the file git rebase -i &lt;sha1&gt; # now you enter a loop, for each commit you set as "edit", you get to basically redo that commit from scratch # assume we just picked the one commit with the erroneous A commit git reset A git commit --amend # go back to the start of the loop git rebase --continue </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload