4.4 Managing Files

Now your repository is starting to come together. With one file, it’s pretty simple right now, but as it grows, some cleanup is necessary.

Files need moving, code needs to be copied around, and some of the everyday cruft from working with your project needs to be ignored.

Renaming and Moving Files

We all write flawless, bug-free code on our first pass. Right? Even though we would like to think that we do, we sometimes get things wrong. Naming a file incorrectly or putting it in the wrong directory is no exception.

You can move a file in Git by typing git mv <original-file> <new-file>. The command tells Git to create new-file with the existing file’s content, and it keeps the history and removes original-filename.

Your ...

Get Pragmatic Version Control Using Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.