I am new to git and I wanted to try the branch feature. I am working with a local repository. The problem is that if I create a new branch and then go back to the master branch, some files are lost.
This is what I do:
I have two directories:
$ ls
g_LT LT
and a source code file lt_mp2.F in the LT directory:
$ ls LT/ | grep lt_mp2.F
lt_mp2.F
The other directory contains a relative symlink to this file:
$ ls -l g_LT/ | grep lt_mp2.F
lt_mp2.F -> ../LT/lt_mp2.F
Both files are lost if I create a new branch and then go back to the master branch. So, let me show this:
Before I create the new branch, let's check that there is nothing to commit:
$ git status
HEAD detached from 2617e8a
nothing to commit, working directory clean here
Let's also check that we are in the master branch and that the last commit is from Oct 13 2016
$ git branch -a
* (detached from 2617e8a)
master
$ git log
commit 3484261bdd585671bf7c74568542a62610c2deaf
Author: [...]
Date: Thu Oct 13 09:25:06 2016 +0200
[...]
Now I create a new branch:
$ git checkout -b testbranch
Switched to a new branch 'testbranch'
The source files are still there:
$ ls LT/ | grep lt_mp2.F
lt_mp2.F
$ ls -l g_LT/ | grep lt_mp2.F
lt_mp2.F -> ../LT/lt_mp2.F
Now I go back to the master branch:
$ git checkout master
Switched to branch 'master'
But now the source files are gone:
$ ls LT/ | grep lt_mp2.F
(no output)
$ ls -l g_LT/ | grep lt_mp2.F
(no output)
Moreover the last commit is suddenly from Dec 2015 instead of Oct 13 2016:
$ git log
commit 634741172ed34cd687fd91f14da45004b3328f8b
Author: [...]
Date: Tue Dec 1 18:54:57 2015 +0100
[...]
What is happening here and why am I losing my source files?