Syntax Error
Syntax Error

Reputation: 1640

Git is not picking up my changed files

I'm trying to create a new branch which contains a different version of my project. Unfortunately the newer version's files, while they have different contents, don't get noticed by git as changed and can't be committed.

The folder\files are nearly identical and were placed into the directory at the same time from a backup. The contents of some files are different and I need these changes reflected in a new branch.

By way of example, take this simple mockup I've tried using 2 text files.

File structure:

project/
├── older/
│   ├── File 1.txt
│   ├── File 2.txt
├── newer/
│   ├── File 1.txt
│   └── File 2.txt

Structure is similar for my actual project, just with a lot more files and subfolders.

Mr JF@Computer MINGW64 ~/Desktop/testproject (master)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

Mr JF@Computer MINGW64 ~/Desktop/testproject (master)
$ stat -c "%y %s %n" *
2018-03-15 15:43:35.764654900 +0000 15 File 1.txt
2018-03-15 15:43:35.765656300 +0000 17 file 2.txt

Mr JF@Computer MINGW64 ~/Desktop/testproject (master)
$ git checkout -b newerbranch
Switched to branch 'newerbranch'

I copy the newer version of File 1 & 2.txt into the repository here, then:

Mr JF@Computer MINGW64 ~/Desktop/testproject (newerbranch)
$ git status
On branch newerbranch
nothing to commit, working tree clean

What's going on here?

Upvotes: 2

Views: 15036

Answers (3)

Van_Paitin
Van_Paitin

Reputation: 4248

So I developed this issue as well. It turns out that since you are certain the only file changes is the folder name. Just rename the working directory folder to something else. Git will pick the new change. Commit the new changes. Then you can rename it to the right name you want. Git will pick it up the changes again and then git has the updated folder name.

Upvotes: 2

jsageryd
jsageryd

Reputation: 4643

I would try these things:

  1. Make sure that the files are not ignored by running git check-ignore -v path/to/file

  2. Run git update-index --really-refresh to refresh the index and ignore any files that may have been muted using git update-index --assume-unchanged

If indeed this is not a user error, I would assume the issue lies with the underlying filesystem and/or how Git interfaces with it.

Upvotes: 13

stackPusher
stackPusher

Reputation: 6512

The comment section isnt big enough for me to paste my own test so ill use this. If i were you i'd double check that the files you copied into the branch really are different. When i repeat your test it works fine:

test $ls
file1.txt file2.txt
test $git status
On branch newerbranch
nothing to commit, working tree clean
test $mkdir new
test $cd new
new $echo "new file1" > file1.txt
new $echo "new file2" > file2.txt
new $cd ..
test $rm file1.txt file2.txt
test $mv new/* .
test $rm -rf new/
test $git status
On branch newerbranch
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)

    modified:   file1.txt
    modified:   file2.txt

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

Upvotes: 0

Related Questions