Git for Windows 2.5.2. I expect that if the index has the uncommited changes, then Git will disable the checking to other branches. But I see other result. Script of the sample:
#!/bin/bash
# script.sh
# Run this script in the Git Bash.
git --version
host="./sandbox"
if [ -d $host ]; then
rm -r $host
mkdir $host
echo \"$host\" directory recreated...
else
mkdir $host
echo $host directory \"$host\" created.
fi
cd $host
git init -q
touch 1.txt 2.txt 3.txt
git add "*"
git commit -qm "Initializing"
git branch
ls
git checkout -qb branch#1
rm 3.txt
echo ABCD >> 1.txt
# git commit -aqm "branch#1_commit#1"
git branch
ls
git checkout -q master
git branch
ls
git checkout -qb branch#2
rm 2.txt
echo 1234 >> 1.txt
# git commit -aqm "branch#2_commit#1"
git branch
ls
git checkout -q master
git branch
ls
I have such output:
bushm@DESKTOP-ISD2NUH MINGW64 /d/src
$ /d/src/script.sh
git version 2.5.0.windows.1
./sandbox directory "./sandbox" created.
* master
1.txt 2.txt 3.txt
* branch#1
master
1.txt 2.txt
branch#1
* master
1.txt 2.txt
branch#1
* branch#2
master
1.txt
branch#1
branch#2
* master
1.txt
bushm@DESKTOP-ISD2NUH MINGW64 /d/src
$
I see the swithing done but the working tree is the same (one file instead of three) after the switching (is not updated). I expected that after the switching of the index its contents will be nullified and branch's last commit will be extracted into the working tree. Why working tree was not updated according the content of the last commit of the master
branch?
Are you sure? I didn't delete files in the master branch. But why the working directory has two files still instead of three when I switch to master? – Andrey Bushman Sep 15 '15 at 14:39