Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 42 lines (29 sloc) 2.426 kb
a324391d » qrush
2009-01-16 Adding Friday's post.
1 ---
c4581adc » matflores
2009-08-11 Unpublishing all the posts
2 published: false
a324391d » qrush
2009-01-16 Adding Friday's post.
3 layout: post
4 title: cleaning up untracked files
5e86e021 » qrush
2009-01-28 Setting category in YAML ftw!
5 category: beginner
a324391d » qrush
2009-01-16 Adding Friday's post.
6 ---
7
8 Our first reader submitted tip comes from "Dav Glass":http://blog.davglass.com/, and it elaborates on a command used to keep your repository nice and tidy. Have a tip you'd like to share? "Submit it!":http://gitready.com/submit.html
9
a8bf8e98 » ngulden
2009-07-17 Fixed missing space in 2009-01-16-cleaning-up-untracked-files
10 Files and directories may pile up in your working directory that are left over from merges, generated, or perhaps got mistakenly put there. Whatever the case, you don't need to ignore them in your @.gitignore@, you just need to remove them. Running
a324391d » qrush
2009-01-16 Adding Friday's post.
11
12 @git clean -n -d <path>@
13
14 will do a 'dry run' of the command and show you just what files and folders are going to be removed. Running it on the "gitready":http://github.com/qrush/gitready gives this output:
15
16 <pre>
17 Would remove _posts/2009-01-16-cleaning-up-untracked-files.textile
18 </pre>
19
20 Which definitely would be bad if it was removed. I haven't added the post to the staging area yet, so the file appears as untracked. If you only want files to be cleaned up and not empty directories, take out the @-d@ option. Once you're sure that you do want to blow away all of those files, doing
21
22 @git clean -d <path>@
23
24 actually performs the deletion. If you omit the @<path>@ git will perform it on your current directory. Also, you may need to throw in the @-f@ option depending on permissions and other situations that may crop up.
25
26 Cleaning also has a few other helpful options: if you want to perform a normal clean and clear out all the files that git usually ignores, the @-x@ flag will help immensely. If you just want to trash the ignored files and nothing else, use the @-X@ option.
27
28 So if we wanted to do a major cleanup:
29
30 <pre>
31 $ git clean -n -d -x
32 Would remove .DS_Store
33 Would remove _posts/.2009-01-16-cleaning-up-untracked-files.textile.swp
34 Would remove _posts/2009-01-16-cleaning-up-untracked-files.textile
35 Would remove _site/
36 Would remove images/.DS_Store
37 Would remove images/_site/
38 </pre>
39
40 That command would clean up files listed under the project's ".gitignore":http://github.com/qrush/gitready/blob/7f51407b796c10beb11fe9e67c0f563d41a92fd8/.gitignore file as well as removing other files and directories that aren't necessary. As always use precaution when running @git clean@, and make sure to double check what you're really deleting.
41
42 As always, if you know of other related tricks with @git clean@ let us know in the comments!
43
Something went wrong with that request. Please try again.