Git and local modifications

I will learn how to use git.

I just did the following test:

  • create folder and 2 files
  • then git init, git add., git commit -m "initial commit"
  • create branch: git branch experimental, git checkout experimental
  • then change the folder name and delete one of the files, then git add., git commit -m "experimental"
  • back to wizard: git check wizard

    Surprise: I do not find the master when I left him; the folder has disappeared. And I have to do git - reset --hard to find my folder.

    Interestingly, I did something wrong or I did not understand how git handles local changes. Thank you 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
+3
source share
1 answer

git add . git add -A.

git add -A .

git add ., git status :

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
#

.

, , :

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

, 'f1'...

+2

Source: https://habr.com/ru/post/1749150/


All Articles