Get git to not show files without a trace

When doing git commit there a way to not display unused files in my editor (defined in $EDITOR )? I know how to do this in the shell ( git status -uno ), but I would like to do this in the editor git status -uno .

Please note that I do not want to ignore these files forever; I just do not want to see them in certain cases.

+12
git
May 05 '10 at 15:08
source share
5 answers

On the git-commit 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.
+12
May 05 '10 at
source share

If you never want to transfer them to your repo, use the .gitignore file to ignore them. More information can be found on the gitignore page. They will not appear as unbroken files when you type your commit message into $EDITOR .

If you just don’t want to see them when done, set the Git config status.showUntrackedFiles to no , as indicated here :

 $ git config --global status.showUntrackedFiles no 
+28
May 05 '10 at 15:13
source share

You can temporarily use the git commit -uno to mask -uno files ( git help commit ).

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

For example, if you want to ignore the bar.foo file and any file with the bar.foo extension, you just need to create a .gitignore file in the root directory of your project containing:

 bar.foo *.bak 

Some files are ignored by the global gitignore file (for example, the dot file and directory are ignored).

+5
May 05 '10 at 15:14
source share

Add the file names β€” or wild cards for the file names β€” to the .gitignore file and add them 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 have to compress the names ' _cgo_ ' with a wild card; another .c 'file is created from the .ec file, so it does not need to be tracked.

+3
May 05 '10 at 15:14
source share

Sometimes notifications are not needed about either a modified repo file or a new file that needs to be added to a repo. However, adding a file name to .gitignore also not be a good option. For example, locally created files that other users cannot generate (for example, files created by an editor) or experimental test code files may not be suitable for display in a .gitignore file.

In these cases, use one of the following solutions:

  • If the file is a modified repo file

    Use the command:

    git update-index --assume-unchanged "$FILE"

    To undo this, use the command:

    git update-index --no-assume-unchanged "$FILE"

    The update-index command does not work with new files that have not yet been added to the repo.

  • If the file is new and not added to the repo

    Add your file name to the repo exclude file:

    echo "$FILE" >> .git/info/exclude

    This also works for modified repo files, but there is no specific undo command for it. The exclude file will need to be edited and the file name removed from it. Or other commands can approximate it:

    ex -s -c"g/^${FILE}\$/d" -cwq .git/info/exclude

    Note that this overwrites the existing exclude file, and if the specified file name contains special characters that can affect the regular expression, the results are unpredictable.

    This use of the exclude file is recommended on the Ignore Files page in GitHub help .

+1
Oct 27 '16 at 20:14
source share



All Articles