git add. The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .
Staged files are those which go into your next commit. If you accidentally added files to the staged area, you can undo this by typing git restore --staged <file> , so in this case, it would be git restore --staged lib.
A staging step in git allows you to continue making changes to the working directory, and when you decide you wanna interact with version control, it allows you to record changes in small commits. Suppose you have edited three files ( a. html , b. html , and c.
To stage a file is simply to prepare it finely for a commit. Git, with its index allows you to commit only certain parts of the changes you've done since the last commit. Say you're working on two features – one is finished, and one still needs some work done.
git reset --soft HEAD^
This will reset your index to HEAD^
(the previous commit) but leave your changes in the staging area.
There are some handy diagrams in the git-reset
docs
If you are on Windows you might need to use this format:
git reset --soft HEAD~1
A Simple Way
Committed files to Staging Area
git reset --soft HEAD^1
Staging to UnStage :(use "git reset HEAD ..." to unstage)
git reset HEAD git commands.txt
or git reset HEAD *ds.txt
here, *--> all files end with ds.txt to unstage.
Refer the below pic for clarity:
To move a commit back to the staging area depends on your last commit. If your last commit was the first(or initial) commit of the repo, then you need to execute
git update-ref -d HEAD
If your last commit is not the first(or initial) commit, then execute
git reset HEAD~
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