To unstage commits on Git, use the “git reset” command with the “–soft” option and specify the commit hash. Alternatively, if you want to unstage your last commit, you can the “HEAD” notation in order to revert it easily. Using the “–soft” argument, changes are kept in your working directory and index.
There is one variant of staging (add) and commit functions that is available to users: interactive staging. This command can help you craft your commits to include only certain combinations and/or parts of files. --interactive (or -i ) is the big brother of --patch .
Using git restore to Unstage This will remove the file from the Staging Area, making sure that it will NOT be part of the next commit. This will discard any local modifications in this file and reset it to its last committed state.
Try git reset --patch filename
; this should do the opposite of git add --patch
, according to the documentation. The short form -p
also works for both commands.
git gui
has a decent GUI to interactively stage or unstage hunks or lines. There are prettier/better GUI clients, but git gui
is lightweight, built-in, and cross platform (lin, win, mac).
https://git-scm.com/docs/git-gui
Simply right click on a hunk to stage/unstage. For lines, highlight the lines first, then right click.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With