Cjku/git: Difference between revisions

320 bytes added ,  28 October 2014
Line 304: Line 304:


OK, let's take a look at reset first:
OK, let's take a look at reset first:
   $ man git-reset
   <span style="color:blue">$ man git-reset</span>
   $ git reset -h
   <span style="color:blue">$ git reset -h</span>
   usage: git reset [--mixed | --soft | --hard] [<commit>]
   usage: git reset [--mixed | --soft | --hard] [<commit>]
     or: git reset <tree-ish> [--] <paths>...
     or: git reset <tree-ish> [--] <paths>...
Line 329: Line 329:


Using it while intending to recover files in working directory form a specific revision. Index or branch ref have nothing to do with this usage.  
Using it while intending to recover files in working directory form a specific revision. Index or branch ref have nothing to do with this usage.  
   $ echo "Jerry" > a.txt
   <span style="color:blue">$ echo "Jerry" > a.txt</span>
   $ git add a.txt
   <span style="color:blue">$ git add a.txt</span>
   $ git commit -m "initial commit"
   <span style="color:blue">$ git commit -m "initial commit"</span>
   $ echo "is cool" >> a.txt
   <span style="color:blue">$ echo "is cool" >> a.txt</span>
   $ cat a.txt
   <span style="color:blue">$ cat a.txt</span>
   Jerry
   Jerry
   is cool
   is cool
   # Oops... that is definitely a typo. He is not cool at all.
   <span style="color:grey"># Oops... that is definitely a typo. He is not cool at all.</span>
   $ git reset HEAD -- a.txt
   <span style="color:blue">$ git reset HEAD -- a.txt</span>
   $ cat a.txt
   <span style="color:blue">$ cat a.txt</span>
   Jerry
   Jerry


Confirmed users
1,643

edits