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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:30:33+00:00 2026-05-12T09:30:33+00:00

I have a project using Git where I’ve branched off of master to rename

  • 0

I have a project using Git where I’ve branched off of master to rename a directory.

The rename in the branch works as expected. When I switch back to the master branch the directory has its original name, but there’s also an empty directory tree with the name that I changed it to in the branch.

Is this the expected behavior?
Am I missing a step?
Do I just need to delete these empty directory trees as they appear?

I know Git doesn’t track empty directories and that may be a factor here.

My current workflow is:

# create and checkout a branch from master
/projects/demo (master)
$ git checkout -b rename_dir

# update paths in any affected files

# perform the rename
/projects/demo (rename_dir)
$ git mv old_dir new_dir

# add the modified files
/projects/demo (rename_dir)
$ git add -u

# commit the changes
/projects/demo (rename_dir)
$ git commit -m 'Rename old_dir to new_dir'

I get to this point and everything is as expected:

# old_dir has been renamed new_dir
/projects/demo (rename_dir)
$ ls
new_dir

The issue comes when I switch back to master:

/projects/demo (rename_dir)
$ git checkout master

# master contains old_dir as expected but it also
# includes the empty directory tree for new_dir
/projects/demo (master)
$ ls
old_dir new_dir

new_dir is an empty directory tree, so git won’t track it – but it’s ugly to have there.

  • 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-12T09:30:33+00:00Added an answer on May 12, 2026 at 9:30 am

    Yes, you can remove it. You can also use git clean -d to remove the directory.

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

Sidebar

Related Questions

I have a project that's using git. When I received the repo, it had
we have just started using a git account of our Django website project so
I have a project using DynamicJasper to create reports. It works fine so far,
I have forked an SVN project using Git because I needed to add features
I'm using git for a personal project at the moment and have run into
I have cloned a svn project repo using git-svn. When I fetch commits, how
I have a project that uses Serve and is version controlled using Git. Serve
I've inherited a project and we are using git. We have a number of
I have a project that is open sourced using git for revision control. Soon,
I am using git for windows to manage a local project. I have two

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.