Git does not detect changes after. Git dir moved, returned

I accidentally moved the .git folder from my working directory before adding and changing some files. When I replaced the .git folder after making the changes, git didn't take the change (I used git add . , git commit -a ). I tried to reproduce the problem and could not. Is there a way to get git to crawl changes in the source tree or some other way to fix this?

+6
source share
2 answers

Instead of trying to β€œinsert” a new git folder into the project, you should:

  • clone a new repo on the same computer.
  • Put all the old files (everything except the .git folder) in the new folder.
  • this will give you all the new changed files and the new ones listed in 'git status'
  • Now you can make and click on them without any problems.

This IMHO is certainly the best approach for this inconvenient case, which I discovered a couple of times. However, you should not do it if the difference between your repo and the central one is large, forcing you to do a megacommit, which is sometimes not desirable.

It has been a long time since you asked, hope this brings some problems.

+1
source

Unfortunately, I do this all the time. I have a .git repository / directory, which I navigate to and from numerous "release versions" (from another VC system). When I migrate .git, I can execute the 'git status' and find what has changed in the new version. Then I do 'git add -A; git commit -m 'release-xyz' 'no problem. I can even change branches without checking using β€œgit symbolic-ref HEAD ...” When I finish the release, I move .git and can use all git diff branch1..branch2 'and other operations.

So, I do not understand what you described as a problem!

0
source

Source: https://habr.com/ru/post/891472/


All Articles