There is a proyect in a GIT repository and this proyect is installed in a production server but GIT is not initialized. Some people have edited files in the source of the production server last months but no GIT there. I have not created the repository or installed on the server but now I want to install GIT in the production server and link the existing source to the GIT repository and commit the changes of the existing source to the GIT repository.
I've tried to copy the files of the production server in a local directory of mi PC and then:
git init
git remote add origin https://.....git
When I run git status
it returns:
On branch master
No commits yet
Untracked files:
...
...
I expected only the distinct files to appear but absolutely all files appear untracked in red.
How I do that?
Thanks in advance
CodePudding user response:
This is going to be tricky. A basic method might be to do git clone ...
to get the current state of the repository, then simply replace all files with your copy of the production server files.
However, this will likely revert files to older versions that you don't want reverted (in addition to including the changes you actually want). I don't know how large your repository is, so I don't know how much of a problem this may be. Careful code review of the changes may work.
Full steps:
$ git clone ... [new_repo_name]
$ rm -rf new_repo_name/** # Deletes existing contents (will not delete .git folder) You can do this manually if you like
$ cp path/to/production/server/copy/** new_repo_name # Copy production server contents across (you can do this manually as an alternative)
$ cd new_repo_name
$ git checkout -b [branch_name] # Create a new branch
$ git add . # Mark everything as to be committed.
$ git commit -m "Replace everything with production server version."
$ git push --set-upstream origin branch_name # Push branch to origin
At this point you can make a pull request into your master branch and carefully code review any changes that you see. You will likely end up wanting to pull in just some of the changes that you see. Best of luck.