I have a git repo that has files in directories.
I have a directory on my Linux box that has similar files from an old version
that came from somewhere.
The Linux box also has thousands of important files that cannot be moved, copied or deleted and are not managed by git.
I need a command that will download/checkout/clone (I dont care) the git files
from that repo and overwight any existing files that are older and/or create them if they do not exist without deleting the non managed data.
Nothing I've tried works, How do you do this ?
For overwriting files if they are older and creating new ones if they do not exist, I think you need to use
rsync. There are many guides online.
rsync also has a
--dry-run option to test the effect of the command you are running.
So you want to end up with a git repo of your latest version, but with a ton of extra files that you don't want git to manage? This might not be a good idea because reasons, but I'm going to go ahead anyway.
Off the top of my head, so be careful:
You could try
git init on the current directory. That will start git managing the directory, but everything will be "new" to git.
git add remote to add your existing repo as a remote. This will give you access to the latest git state without changing the working directory.
git reset origin/master --hard should cause any tracked files to be overwritten with the latest versions from
origin. If you have files that are newer on your local filesystem, they will be overwritten! So watch out!
(But you may want to reconsider the whole thing. I would be happier with a fresh checkout of my project on the Linux box, in another directory, and keep the old version separate)