title: What does Git actually do when I run git checkout branch_name?
body: <p>I have one repository which is called <code>test-repo</code>.</p>
  
  <p>Right now, I have two branches on that repository, called:</p>
  
  <ol>
  <li>master</li>
  <li>master-bkp</li>
  </ol>
  
  <p>Both branches contains only one file called <code>test.txt</code>.</p>
  
  <p><code>test.txt</code> in master contains </p>
  
  <pre><code>hello I am here
  </code></pre>
  
  <p>and <code>test.txt</code> in master-bkp contains </p>
  
  <pre><code>hello I am there
  </code></pre>
  
  <p>Now, in my local repository I write:</p>
  
  <pre><code>git checkout master
  git merge master-bkp
  </code></pre>
  
  <p>Now <code>test.txt</code> in master contains </p>
  
  <pre><code>hello I am here
  hello I am there
  </code></pre>
  
  <p>Can someone explain how Git works internally when I trigger these two commands?</p>
  
  <pre><code>git checkout master
  git checkout master-bkp
  </code></pre>
  
  <p><strong>Note :</strong> Please don't give opinions on <code>git checkout</code>, I need an explanation about internal logic behind it. </p>