Skip to main content

Section C.1 Uh Oh, I Staged the Wrong Files!

Once you get the hang of Git, it’s easy to just fly through the three-step process. In doing so, you will inevitably stage (with git add) a file or folder on accident. This is relatively simple to fix. To undo this, follow the next procedure.
Oh shoot. What if you add a file you didn’t mean to? This is one reason why there are so many steps to sending files to GitHub. Humans make mistakes and Git gives you the chance to correct any. Should you ever add a file you didn’t mean to add, revist this procedure.

(a)

Identify the file name(s) and extension(s) of the file(s) you mistakenly added.

(b)

Use git restore --staged <your-file-name(s)> to un-stage any files. Like git add, this command can be run many times.

(c)

It might be wise to verify with git status that everything looks good.