1

Is there a way to mark a file in Git such that a "git add ." won't stage it but have it still show up under git status?

I know this sounds crazy, but the reason is I have some local script files that I'd like to see in my git GUI (Tower) browse window, however I don't want them added to the repo when I "stage all".

If I untrack the files and set status showUntrackedFile = Normal (or all) they show up, but then they get added back in by "git add ." or "Stage All". If I put them in .gitignore they won't get added/staged but they won't show up in the browse window either (which at least in tower is effectively git status).

Is there a way to get ignored files to show up in git status? I'm guessing no, but am hoping for a cleaver work around?

jb510
  • 358
  • 1
  • 18

3 Answers3

2

I am not sure if the other answerers are reading the man, but:

git status --ignored

shows ignored files as well.

http://www.kernel.org/pub/software/scm/git/docs/git-status.html

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • 2
    One issue that I found with that is if you do a `git status --ignore` and there are no changes, it doesn't list the ignored files. I couldn't figure out how to always get the ignored files to display – Andy Jul 22 '11 at 23:09
  • @Andy - Yeah that part is weird, but.....`echo "a"> blah&&git status --ignored&&rm blah` – manojlds Jul 22 '11 at 23:22
1

You could create an alias that calls git status and git ls-files -o -i --exclude-standard after status... Kind of a hack, but it should work.
I just tested this and it works

  • Set the alias:

    git config --global alias.st '!git status && echo "**IGNORED FILES**" && git ls-files -o -i --exclude-standard'

  • Run git st instead of git status

Similar question
How to call multiple commands in an alias

Community
  • 1
  • 1
Andy
  • 44,610
  • 13
  • 70
  • 69
  • This works reliably `git ls-files -o -i --exclude-standard` but I'm not sure if/how to integrate it in Tower, but it sets me down a path. – jb510 Jul 23 '11 at 01:30
-1

I don't think so; that would actually break the intent of git ignore.

From http://git-scm.com/docs/gitignore

A gitignore file specifies intentionally untracked files that git should ignore.

I know it's probably not the answer you're hoping for, but I think it's accurate.

JSager
  • 1,420
  • 9
  • 18