Cleaning your mistakes
The first thing to know is that you can always clean your mistake with Git. Sometimes this will be hard or painful for your code, but you can do it!
Let's start this section with how to remove untracked files:
Erik@server:~$ git clean -n
The –n
option will make a dry-run (it's always important to see what will happen before you regret it).
If you want to also remove directories and hidden files, use this one:
Erik@server:~$ git clean -fdx
With these options, you will delete new directories (-d
) and hidden files (-x
) and be able to force them (-f
).
Reverting uncommitted changes
To explain this section, we will use an example. Let's suppose you edited a file on the production working directory, but didn't commit it. On your last ...
Get Git Best Practices Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.