Adding Git to an old project

What if we have an old project that is not yet under version control? Like our first test application TestApp1. Basically we should perform three actions: 1) create a Git repository under TestApp1 folder, 2) add files to be committed and 3) commit the files to the repository. We could also mark the user settings file (TestApp1.pro.user) to be ignored as we don’t want to add it to the repository.

First the ignore part. If we want Git to ignore certain files we can create a file called .gitignore and put the file names there. E.g. to ignore the user settings file enter the following command in the Git Bash console:

$ echo '*.user' > .gitignore

Next let’s create the repository:

$ git init

Add the files from the project folder (use the dot to denote the current folder):

$ git add .

And finally commit the files to the repository:

$ git commit -m "Repository created"

If we now check for untracked files there shouldn’t be any.

$ git status -u

Git-19

1 7 8 9 10 11 18