Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git doesn't see a file... how to understand what's wrong?

Tags:

git

Problem 1. I'm trying to let git track my file "altro.src" but without success. The file is completely ignored by git, even if is not listed in .gitignore, it is not shown with --ignored and even if i try to git-add it, it is not considered.

I'm a newbie with git (third commit... and I'm already stuck) but I have some long experience with hg.

Here is some commands to show the problem:

$ ls -al altro.src
-rw-r--r--  1 myuser  staff  560 28 Mar 09:02 altro.src

$ git status .
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    typechange: moebius.html

no changes added to commit (use "git add" and/or "git commit -a")

$ cat .gitignore
*~
.DS_Store

/index.html
/index.en.html
/moebius.html
/moebius.en.html
/altro.html
/altro.en.html
$ git status . --ignored
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    typechange: moebius.html

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

    .DS_Store
    .gitignore~
    altro.en.html
    altro.html
    altro.src~
    base.src~
    build_site.py~
    index.en.html
    index.html
    moebius.en.html
    moebius.src~

no changes added to commit (use "git add" and/or "git commit -a")
$ git add altro.src
$ git status .
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    typechange: moebius.html

no changes added to commit (use "git add" and/or "git commit -a")

Problem 2. I don't understand what "typechange" on file moebius.html means and how to get rid of that message (moebius.html is in my .gitignore and I want it to be ignored).

like image 553
Emanuele Paolini Avatar asked Oct 21 '22 11:10

Emanuele Paolini


1 Answers

I suspect it's just that altro.src is unchanged since you checked it in previously. Git doesn't warn you if you try to stage an unchanged file, but it won't add it to the staging area (index) so it won't show in the git status. In other words, if you ask Git to add something that's already there, it has no work to do.

You can check this by running git diff altro.src (might show no changes) and git log altro.src (to see which of your commits added it before).

The typechange note is telling you that the type of file has changed (e.g. from a regular file to a link to a file).

like image 113
Matthew Strawbridge Avatar answered Oct 23 '22 00:10

Matthew Strawbridge