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 6363067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:59:20+00:00 2026-05-24T23:59:20+00:00

How do I solve this chicken & the egg situation? I decided to rename

  • 0

How do I solve this “chicken & the egg” situation?

I decided to rename a Java class in Eclipse (say, from one.java to two.java). Eclipse refactoring let me do that without a hitch.

Then, I went to git and typed:

git mv myproj/src/com/ate/lib/one.java myproj/src/com/ate/lib/two.java

and received the error:

fatal: bad source, source=myproj/src/com/ate/lib/one.java, destination=myproj/src/com/ate/lib/two.java

I understand why this is happening, but if I do git mv before refactoring, Eclipse will not like this…

What is a good approach to tackle this?

  • 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-05-24T23:59:20+00:00Added an answer on May 24, 2026 at 11:59 pm

    git mv is merely a convenience method. git does not “track” renames (that is, it can detect them, but they are not recorded as an operation like an add or remove). To stage and commit your refactoring:

    git rm myproj/src/com/ate/lib/one.java
    git add myproj/src/com/ate/lib/two.java
    git commit
    

    git rm tells git to stage removing the file in the index. Although you have already “removed” the file (by moving it) in the working directory, you have not told git that you want to version this removal. The difference between rm and git rm is that the first works on the working dir, and the second works on the index too (changes to be versioned by git).

    git add simply adds the file content at the new location.

    EDIT:

    I previously had git rm --cached, out of personal habit, but apparently git rm does not complain if the file does not exist in the working dir. git rm --cached is still useful when you want to remove a file in versioning, but keep the file in the working dir.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello can anybody solve this please I'm creating the object in the action class
I can't solve this problem can you help me please. <%@ page language=java contentType=text/html;
I'm trying to solve this: A user class with 50 fields is defined in
Please help me to solve this. I trying to get value from textview and
After being unable to solve this issue , I decided to try to implement
Please help me to solve this: I have two strings for email-id and password
Can you solve this without throwing an error? The answer is a one-liner. This
Hi im trying to solve this problem, I'm fetching data from DB and create
Solve this equation for x, (1 + x)^4=34.5 . I am interested in the
I'm trying to solve this flickering problem on the iphone (open gl es game).

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.