tags:

views:

142

answers:

4

Is there a way to , when doing

git commit 

to not display the untracked files in my $EDITOR?

I know how to do so in the shell, using git status -u no, but I'd like do it in $EDITOR as well

EDIT: I should have stated, I do not want to ignore these files forever, just not see them on certain occasions...

+4  A: 

If you don't ever want to commit them to your repo, use a .gitignore file to ignore them. More details can be found on the gitignore man page. They won't show up as untracked files when entering your commit message in your $EDITOR.

If you simply don't want to see them when committing, set the Git config variable status.showUntrackedFiles to no, as noted here:

$ git config --global status.showUntrackedFiles no
mipadi
Hmm, this is an interesting thing to know. Thanks
chiggsy
+3  A: 

You can temporary use the git commit option -uno to mask untracked files (git help commit).

If you want a permanent solution use the .gitignore file.

For instance, if you want to ignore the file bar.foo and any file with the .bak extension, you juste have to create a .gitignore file in the root directory of your project containing :

bar.foo
*.bak

Some file are ignored by a global gitignore file (for instance, dot file and directory are ignored).

Lohrun
+2  A: 

Add the file names - or templates (wild cards) for the file names - to the .gitignore file and add that to the repository:

git add .gitignore
git commit -m 'Added .gitignore file'

For example, for my Go repository, I have a .gitignore file containing:

*.o
*.a
*.so
*.pl
*.6
*.out
_obj/
_cgo_defun.c
_cgo_export.c
_cgo_export.h
_cgo_gotypes.go
*.cgo1.go
*.cgo2.c
example/example
ifix1/esqlc-cmds.c

I should probably compress the '_cgo_' names with a wild card; the other '.c' file is generated from a '.ec' file so it does not need to be tracked.

Jonathan Leffler
+6  A: 

From the git-commit man page:

       -u[], --untracked-files[=]
           Show untracked files (Default: all).

           The mode parameter is optional, and is used to specify the handling of untracked
           files. The possible options are:

           ·   no - Show no untracked files

           ·   normal - Shows untracked files and directories

           ·   all - Also shows individual files in untracked directories.

               See git-config(1) for configuration variable used to change the default for
               when the option is not specified.
jcordasc
Thanks, that works.
chiggsy
Great thing about git is they're really trying to keep command line options consistent between commands with similar functionality.
jcordasc