Search code examples
gitgithubdeploymentgitlabversion-control

Best way to add git to existing project


We inherited a site with zero version control / no info on how it was built - only enough info to ssh onto the server. We want to add git, so we can start developing locally and pushing updates via git.

What's the best way to do this, without breaking anything?

My first inclination is to create a blank repo on github, initialize a git repo inside the site root (which I'm 99% sure about..), git add ., git commit -m "Initial commit" and push everything to github. Then clone the repo and create a staging and local site.

I just want to double confirm that is a sound plan, because I don't do this very often (usually start off projects with git from the very beginning). And I don't want to break anything while I'm poking around on the server.

Thank you :)


Solution

  • In such situation I use the following checklist:

     1. git init
     2. git remote add origin <REMOTE-REPO-URL>
     3. Write a good '.gitignore` file.
     4. git add --all
     5. git commit -m "Initial commit"
     6. git push