Checking out a git branch while in a path that exists only in the initial branch -


can me make sense of quirk i've found git?

here's how reproduce quirk:

$ mkdir git-test && cd git-test $ git init initialized empty git repository in /tmp/git-test/.git/ $ echo hello > world $ git add world $ git commit -m'first commit' [master (root-commit) 5f68103] first commit  1 file changed, 1 insertion(+)  create mode 100644 world 

cool, right far; let's branch off:

$ git checkout -b a_branch $ mkdir a_dir $ echo foo > a_dir/bar $ git add a_dir/bar $ git commit -m message [a_branch (root-commit) 2fbef71] message  1 file changed, 1 insertion(+)  create mode 100644 a_dir/bar 

ok, here comes quirk!

$ cd a_dir $ pwd /tmp/git-test/a_dir $ git checkout master switched branch 'master' $ pwd /tmp/git-test/a_dir 

wtf!? path not exist in branch!

$ ls total 0 

even ls seems work...

$ cd .. $ ls world 

the directory `a_dir' has magically disappeared!

how possible?

if understand correctly, has not git.

your current working directory being removed process (in case git branch switch). same thing happen if rmdir current working directory.

$ cd /tmp $ mkdir test $ cd test $ rmdir ../test/ $ pwd /tmp/test $ ls /tmp/test ls: /tmp/test: no such file or directory 

you can see similar effect when deleting files open: disappear file system, program opened them can still access them, , disk space reclaimed after program closes them. note behaviour different between unixy systems , windows. windows not let delete them in first place.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -