Unstaging Changes1:51 with Jay McGavren
Staged a file, but decided you don't want to commit it? We'll show you how to unstage it.
Make sure that you're in the repository directory,
medals, by typing the command
- Let's suppose we've added a
<h1>Sale: 100% off!</h1>element in
- We can stage our changes:
git add medals.html
- Now suppose we get word that the store manager doesn't want to do the 100% off sale anymore. But what can we do? We've already staged the code to announce the sale!
- If we run
git status, we'll see a help message in the output: "use
git reset HEAD <file>...to unstage"
- So, let's try that:
git reset HEAD medals.html
- If we run
git statusagain, the
medals.htmlfile will be back in the "Changes not staged for commit" section.
Now, here's the important thing. You don't have to remember this
git reset HEAD command if you don't want to. If you ever have staged changes that you want to unstage, just remember to run
git status, and it will show you the command you need to run.
If you'd like to know more about the
git reset command, check out this link: Git Reset: Atlassian Git Tutorial
You need to sign up for Treehouse in order to download course files.Sign up