Cleaning a repository

It is not reasonable to store all the files in the version control. For example, from program code it is enough to store the source code files, but it is useless to store the files generated by the compiler, because you can generate them again if you have the source code files available. Generated files are typical very large, and storing them would only waste storage capacity. In addition, compilation files in your repository may prevent automatic tests from working properly.

If there are no unfinished jobs, the ideal printing of git status would be as:

# On branch main
nothing to commit, working directory clean

If this is not the case, clean your personal repository by going through all the files listed as ”untracked files”:

  • If a file is important, but you have just forgotten to add it in Git, do so now (recall 3 steps: git add, git commit, and git push).
  • If a file is not important, remove it.
  • If a file contains something that you do not generally want to store in Git (e.g. files that are automatically stored by the editor used), add such a rule in .gitignore file that eliminates these files in status listing. (Next exercise will teach you how to create a .gitignore file.)

Especially, at the beginning, when using Git is not totally straightforward, it is better to check status preferably too often than too seldom. Status command helps in keeping track of which modification you are doing.

After above kind of cleaning, your status should be clean, and it should be easy to start practicing command line version control with frequent status checking.

When you have created a .gitignore file in your personal repository in the next exercise, the result of command git status should be much clearer. It lists no build directories generated by Qt Creator nor local setting files any more. Such files are not wanted to be added in Git.

Important

The next exercise (creating a .gitignore file) is highly recommended, since it makes working on this course easier.