Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Git to Acknowledge Previously Moved Files

Tags:

git

I've moved a bunch of files around manually without thinking, and can't find a way to get git to recognize that the files are just moved and not actually different files. Is there a way to do this other than removing old and adding the new (and thus losing the history), or redoing all the changes with git-mv?

like image 778
Michael Avatar asked Sep 16 '09 03:09

Michael


People also ask

Can git detect moved files?

In Git's case, it will try to auto-detect renames or moves on git add or git commit ; if a file is deleted and a new file is created, and those files have a majority of lines in common, Git will automatically detect that the file was moved and git mv isn't necessary.

How do I rename a directory in git without losing history?

emiller/git-mv-with-history. git utility to move/rename file or folder and retain history with it. # git-mv-with-history -- move/rename file or folder, with history. # Git has a rename command git mv, but that is just for convenience.

In which folder git commit history is maintained?

Git stores the complete history of your files for a project in a special directory (a.k.a. a folder) called a repository, or repo. This repo is usually in a hidden folder called . git sitting next to your files.


1 Answers

To have git remove files that are removed or moved already, just enter

git add -u 
like image 50
Hugo Avatar answered Oct 13 '22 00:10

Hugo