Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git doesn't detect changes after .git dir moved, returned

Tags:

git

I accidentally moved the .git folder out of my working directory before adding & changing some files. When I replaced the .git folder after making the changes, git didn't pick up the changes (I used git add ., git commit -a). I tried to reproduce the issue and failed. Is there a way to force git to scan for changes in a source tree, or some other way to fix this?

like image 392
Matt Hampel Avatar asked Jun 27 '11 17:06

Matt Hampel


1 Answers

Instead of trying to "fit" the new git folder into the project, you should:

  1. clone a new repo in the same computer.
  2. Put all the old files (all but .git folder) into the new folder.
  3. this will give you all the new modified files and new ones listed in 'git status'
  4. you now may commit and push them without any issue.

This IMHO is by far the best approach for this awkward case, which i found myself in a couple of times. However will not do if the difference between your repo and the central one it's to big, forcing you to make a megacommit which it's sometimes not desirable.

It's been a long time since you asked, hope this will bring some ligth to the issue.

like image 87
Joako-stackoverflow Avatar answered Oct 11 '22 15:10

Joako-stackoverflow