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

  • Home
  • SEARCH
  • 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 8336341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:57:31+00:00 2026-06-09T03:57:31+00:00

I have a directory tree in my repo. I do a git add -A

  • 0

I have a directory tree in my repo. I do a git add -A first time.

Now I remove a directory with files by mistake and do a:

git add -A

I lose the entire directory in my repo too. Or is there a way to retrieve my lost directory?

Also suppose I do a git add . I wouldn’t have lost my directory, am I correct?
So I take it there is no way to track deletion of files using git?

For example I deleted 3 files when I did an commit yesterday and if I want to go back to yesterday’s version of all files and directories would I see the deleted files?

  • 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-09T03:57:32+00:00Added an answer on June 9, 2026 at 3:57 am

    My understanding of your question is this:

    1. You have a git repository with some files and directories.
    2. You’ve added everything initially (git add -A). Presumably you’ve also committed.
    3. You delete a directory from your repository (rm -rf dir), then add the changes (git add -A). I assume you then commit.

    If this is the case, then yes, you’ve removed the directory from the repository. From the git-add man page:

    
    -A, --all
       Like -u, but match  against files in the working tree in addition
       to the index. That means that it will find new files as well as staging modified
       content and removing files that are no longer in the working tree. 
    

    git add -A will add all changes to the repository – additions, removals, the lot.

    So I take it there is no way to track deletion of files using git?

    I’m unsure what you mean by this. You can track deletion of files from git. Read the man-page for git-rm. Or, delete a file, then run git add -A: git will add the deleted file to the index, allowing you to commit the deletion. So the deletion is tracked.

    Also suppose I do a git add . I wouldn’t have lost my directory, am I correct?

    You wouldn’t have staged the deletion of the directory to the git index, correct. The directory is still gone from the git working directory, though, because you deleted it.

    For example I deleted 3 files when I did an commit yesterday and if I want to go back to yesterday’s version of all files and directories would I see the deleted files?

    You add a file to your repository. git add file; git commit -m "added file". Let’s call this commit A.
    Next you delete that file, and commit the change to the repository: rm file; git add -A; git commit -m "Deleted file" (another way is git rm file). Let’s call this commit B.

    If you checkout commit B, the files are not there. You deleted them, and the commit reflects this.
    If you checkout commit A, the files are there. That commit contains the files.

    To answer your question:

    For example I deleted 3 files when I did an commit yesterday and if I want to go back to yesterday’s version of all files and directories would I see the deleted files?

    No. You won’t see the files in yesterdays commit, because you’ve committed the deletion. If you checkout the commit before yesterdays commit, though, the files are there.

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

Sidebar

Related Questions

I have a directory tree under SVN control, and I want to add and
I have a directory tree with sub-directories, and I want to add it to
I have a large directory tree of files, and am using the following script
I have some files in a directory tree which is being served over HTTP.
I have a directory tree in which there are some files and some subdirectories.
I have an application which keeps its data in a directory tree. Now, I
In my personal git repo, I have a directory that contains thousands of small
I have a git repository that is just a directory tree (/myprogram/src/com/mycompany/test) with some
I have a normal repo where there is a working tree and a .git
So I have a directory tree as follows: pluginlist.py plugins/ __init__.py plugin1.py plugin2.py ...

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.