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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:29:15+00:00 2026-05-15T04:29:15+00:00

I am discovering how to use git. I just made the following test: create

  • 0

I am discovering how to use git.

I just made the following test:

  1. create a folder and 2 files
  2. then git init, git add ., git commit -m “initial commit”
  3. create a branch: git branch experimental, git checkout experimental
  4. then change the name of the folder and delete one of the files, then git add ., git commit -m “experimental”
  5. go back to master: git checkout master

    Surprise: I do not find the master as I left it; the folder has disappeared. And I have to do a git -reset –hard to find my folder.

    I wonder if I did something wrong or if I have not understood how git manages local changes. Thanks for your help.

Detailed scenario:

mkdir GitTest
cd GitTest/
mkdir Folder1
echo "master" > Folder1/File1.txt
echo "master" > File2.txt
git init
git add .
git commit -m "init"
git branch expe
git checkout expe
mv File2.txt File3.txt 
mv Folder1/ Folder1-exp/
echo "expe" >> Folder1-exp/File1.txt 
git add .  
git commit -m "expe"
git checkout master
ls
git checkout expe
ls
  • 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-15T04:29:15+00:00Added an answer on May 15, 2026 at 4:29 am

    That would be because of the difference between git add . and git add -A.

    Only git add -A will record new files and deleted files.

    When you did your second git add ., here what git status had to say:

    C:\HOMEWARE\git\tests\p2>git status
    # On branch exp
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   f2/f1b.txt
    #
    # Changed but not updated:
    #   (use "git add/rm <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       deleted:    f1/f1a.txt
    #       deleted:    f1/f1b.txt
    #
    

    The working tree had the first directory deleted.

    So when you switched back to master, that working tree was preserved:

    C:\HOMEWARE\git\tests\p2>git checkout master
    D       f1/f1a.txt
    D       f1/f1b.txt
    Switched to branch 'master'
    

    Hence the disappearance of ‘f1‘…

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

Sidebar

Related Questions

I am just learning how to use Terracotta after discovering it about a month
After discovering lambda expressions, and their use as anonymous functions, I've found myself writing
I'm currently discovering scala and I was wondering if I could use traits with
I'm having trouble discovering exactly what I need to implement in order to use
I was reading today about researchers discovering that NVidia's Phys-X libraries use x87 FP
I'm discovering a simple solution for singular-plural keywords searches. I heard about stemming but
I've been working in Silverlight recently and I've slowly been discovering that as simple
I'm attempting to make use of configuration transformations in a continuous integration environment. I
I am discovering Pentaho DI and i am stuck with this problem : I
I want to publish some kind of feed that outlook can read and use

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.