开发者

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

开发者 https://www.devze.com 2023-03-15 22:30 出处:网络
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 u

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?


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.


I, unfortunately, do this all the time. I have a .git repository/directory that I move into and out of numerous 'release versions' (from another VC system). When I move the .git in, I can perform a 'git status' and find what has changed in the new release. I then do 'git add -A; git commit -m 'release-xyz'' without any problem. I can even change branches, w/o a checkout, using 'git symbolic-ref HEAD ...' When I'm done committing a release, I move the .git out and can do all the 'git diff branch1..branch2' and other operations as well.

So, I don't see what you described as a problem!

0

精彩评论

暂无评论...
验证码 换一张
取 消