Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Checking out a branch moves the local <code>HEAD</code> pointer so that it's pointing at the same commit that the branch references. For example:</p> <p>When on branch <code>mybranch</code> (the <code>C</code>s are commits):</p> <pre><code> HEAD | V master mybranch | | V V C1 -------&gt; C2 -------&gt; C3 </code></pre> <p>After running <code>git checkout master</code>:</p> <pre><code> HEAD | V master mybranch | | V V C1 -------&gt; C2 -------&gt; C3 </code></pre> <p>This also moves files in your working directory as required so that it is a perfect snapshot of what the project looked like at that commit. It does not delete or alter commits, so you won't lose work in one branch by checking out another.</p> <p>What has happened in the case of a "detached head" as described in that other question is that <code>C3</code> is not associated with a branch. In order to fix this, you need to update the commit that the <code>master</code> branch points to so that it includes the new stuff (<code>C3</code>). Checking out <code>master</code> tells git that you are now working with the master branch, then doing a hard <code>reset</code> with the SHA1 of the commit that you <em>want</em> to be at the tip of your <code>master</code> branch updates the branch references to what you want.</p> <p><strong>Edit:</strong></p> <p>In this case, a detached head was not the issue. Just remember that committing and pushing are two different things in git. Committing does not communicate with a central repository like it does in Subversion. After you make changes to your working directory, you run <code>git add filename</code> once for each file you've changed, where <code>filename</code> is the name of the file. Once all the files have been added to the index, you commit them with <code>git commit</code>.</p> <p>A shorthand for this is to use <code>git commit -a</code> which will automatically add modified files to the index before committing. This allows you to skip the <code>git add</code> steps. Note that <code>git commit -a</code> will only add <em>modified</em> files. If you're introducing a new file that has never been committed, you must manually add it with <code>git add</code>.</p> <p>Once your commit has been made, you can run <code>git push</code> to send that commit to your remote repository and update the remote branches. This only does the remote communication stuff. Unlike Subversion, the commit itself is handled locally, without any interaction with the server.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload