Skip to Main Content
Pragmatic Guide to Git
book

Pragmatic Guide to Git

by Travis Swicegood
November 2010
Beginner content levelBeginner
160 pages
2h 50m
English
Pragmatic Bookshelf
Content preview from Pragmatic Guide to Git
9 Undoing Uncommitted Changes

Git’s two-step process for tracking a commit means you can have files that are staged for commit that you’re not ready to commit. You use git reset HEAD or git rm --cached depending on the circumstance.

Scenario 1: You staged a change to a file and want to unstage it—use git reset HEAD. This is the most common use. You’re telling Git, “Change the index—the staging area—to the latest version of this file.”

Scenario 2: You have a new file that’s been staged that you don’t want to commit now—use git rm --cached. Normally, git rm is used to remove files from your repository, but adding the --cached option tells Git to leave your working tree alone.

Another common problem is making changes that you want to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pragmatic Version Control Using Git

Pragmatic Version Control Using Git

Travis Swicegood
Git Version Control Cookbook - Second Edition

Git Version Control Cookbook - Second Edition

Kenneth Geisshirt, Emanuele Zattin(EUR), Aske Olsson, Rasmus Voss
Git for Programmers

Git for Programmers

Jesse Liberty

Publisher Resources

ISBN: 9781680500028Errata