Skip to content

File Naming Conventions

Naming new file versions

When developing a new version of a file, the new version will keep the current file name and the old file will be renamed.

For example, given a file called MyComponent.vue. When you create a new version of this file, you would

  1. Rename MyComponent.vue -> MyComponent.backup-v1.vue
  2. Create a new file called MyComponent.vue

This has a couple of advantages

  • you can more easily throw away old code, because you have to do less renaming afterwards
  • the normal named version is always the latest version, you don’t have to dig through v2s, v3s, etc to figure out the last version
  • It keeps change / commit history, instead of overwriting the file when you renaming the v2 to the v1.

Keeping the Git history

Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn't matter, as long as the move operation is committed separately from any changes to the file.

To rename a file in Git while keeping its history intact, use the git mv command. This command is essentially a shortcut for removing the file with git rm and then adding it with git add under the new name. Make sure to commit this seperately.