Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:06:08+00:00 2026-06-12T13:06:08+00:00

Questions about renaming files in Git have been asked before, but I can’t work

  • 0

Questions about renaming files in Git have been asked before, but I can’t work out a solution to my specific problem.

I have moved and edited multiple files (I didn’t use git mv – unfortunately it’s now too late for that). Now I want it so when my colleague pulls from my repository, having made his own edits to those same files (without moving them), it successfully merges my changes with his in the file’s new location. To successfully merge, Git clearly needs to know that these are the same files.

Is Git clever enough to work this out on its own? It seems hard to believe. And if so, how can I be sure that a particular file move will be picked up by Git – even if the contents has changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:06:09+00:00Added an answer on June 12, 2026 at 1:06 pm

    Git doesn’t actually track renames in the repository, it uses a diff heuristic to determine if you renamed a file to another. That is to say, if you git mv a file and then replace the contents completely, it is not considered a rename, and you do not need to use git mv for it to detect renames.

    For example:

    % mv d.txt e.txt
    % git rm d.txt
    rm 'd.txt'
    % git add e.txt
    % git commit -m"rename without git mv"
    [master f70ae76] rename without git mv
     1 file changed, 0 insertions(+), 0 deletions(-)
     rename d.txt => e.txt (100%)
    % git diff --summary --find-renames HEAD~1 HEAD
     rename d.txt => e.txt (100%)
    

    Similarly, git mv doesn’t mean that the file will be renamed, it will still use the diff algorithm:

    % git mv e.txt f.txt
    % echo "Completely replacing f.txt" > f.txt
    % git add f.txt
    % git commit -m"git mv doesn't help here"
    [master 068d19c] git mv doesn't help here
     2 files changed, 1 insertion(+), 14 deletions(-)
     delete mode 100644 e.txt
     create mode 100644 f.txt
    % git diff --summary --find-renames HEAD~1 HEAD
     delete mode 100644 e.txt
     create mode 100644 f.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Several questions about accessor methods in C++ have been asked on SO, but none
I'm aware that questions about the stack vs. the heap have been asked several
There are several other questions about this topic that I have gone through, but
There are tons of questions about this topic, but I have a slightly altered
Questions about threads are in no shortage, I know, but I can't seem to
I know there are already several questions about renaming files by using a version
I've heard questions about bypassing this security feature of Windows 7 before, but I
I have some questions about vector ; How can I append one vector in
There have been some questions about whether or not JavaScript is an object-oriented language.
I have few questions about ssis transction isolation levels. consider a scenario:I have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.