0

I'm new to Git and have done some work on some .scss files which compile into .css files with Gulp.

I've done my work and am now ready to push my altered files to Github. However, I see 3 untracked files when I do git status: a log, a .js and a .scss.

How did these files get marked as untracked? I thought I had to specify that myself.

MeltingDog
  • 14,310
  • 43
  • 165
  • 295
  • All new files that appear in the working area and which have not been in the repo yet are untracked. – fracz Oct 05 '16 at 05:42

2 Answers2

0

In git, all files which are in the working directory but haven't been explicitly added (i.e. git add) are marked as "untracked". This effectively means that they exist, but git is not keeping track of changes in them.

Sinkingpoint
  • 7,449
  • 2
  • 29
  • 45
  • Ah, ok. So, in that case, why were the other files tracked? I haven't used git add yet, so shouldn't they all appear as untracked? – MeltingDog Oct 05 '16 at 06:02
  • Not okay because, by `git add` you also end up adding the contents of these files to index area - when you only wanted to track these files. – prabodhprakash Oct 05 '16 at 06:08
  • did you clone the repo @MeltingDog or it is the new repo that you have started? – prabodhprakash Oct 05 '16 at 06:09
  • It's a new repo. Yeah that's what I was saying: I havent used git add with this branch yet, so how could they be tracked? – MeltingDog Oct 05 '16 at 06:55
  • 1
    @MeltingDog By right in a clean git repo, nothing should be tracked. If you do have tracked files in a clean git repo that's very odd – Sinkingpoint Oct 05 '16 at 07:04
0

A file by default is in untracked state. You have to add it to git to ensure that git starts tracking it.

You can track a particular file by writing the following

git update-index --no-assume-unchanged <path_to_file>

if you with to untrack a file again, you can do it via

git update-index --assume-unchanged <path_to_file>

git update-index registers a file to index - thus, does start tracking the file. However, as other answers have posted git add also adds the contents of the file to index - which adds to tracking the file and adds this file to staging area (ready to be committed)

prabodhprakash
  • 3,825
  • 24
  • 48
  • 1
    For someone who has just started learning git this is unnecessarily complicated. I can't name a situation outside niches where you would want this behaviour over just staging changes to a file with `git add`. Heck, even the help for `git status` gives "use "git add" to track" – Sinkingpoint Oct 05 '16 at 06:58
  • "unnecessarily complicated" - you still have to tell the right things. Rather, I feel, when you are learning new stuff, it is the best time to find right things, otherwise, there is a tendency to ignore right things in name of complicated stuffs ! – prabodhprakash Oct 05 '16 at 07:04