Git Tips
This post have some recurrent tips that I use with git.
Moving files/folders
When you need to move or rename a file/folder that is in a git repository, then you’ll need to take special care (more than using mv
). The original information was taken from Rename files and folders with git
How to..
We’ll use git mv <source> <destination>
to rename a folder/file. Assuming we have the folder my_folder and we’d like to rename it to the_folder then:
# move the folder/file with git mv
git mv my_folder the_folder
# add the changes to the index and commit them after renaming with git mv.
git add -u the_folder
git commit -m "renaming my_folder to the_folder"
The option -u in git add
will update the index for already tracking files. This removes as well as modifies index entries to match the working tree, but adds no new files.