Skip to content

Commit af3721d

Browse files
committed
inspecting basically done
1 parent e5ef5fe commit af3721d

File tree

3 files changed

+514
-4
lines changed

3 files changed

+514
-4
lines changed

_layouts/reference.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ <h3><a href="/branching">Branching and Merging</a></h3>
6161
<li><a href="/branching/#branch">checkout</a></li>
6262
<li><a href="/branching/#merge">merge</a></li>
6363
<li><a href="/branching/#log">log</a></li>
64+
<li><a href="/branching/#tag">tag</a></li>
6465
</ul>
6566
</div>
6667

branching/index.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,5 +690,90 @@ <h2>
690690
</div>
691691
</div>
692692

693+
<div class="box">
694+
<h2>
695+
<span class="docs">
696+
<a target="new" href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html">docs</a> &nbsp;
697+
<a target="new" href="http://progit.org/book/">book</a>
698+
</span>
699+
<a name="log">git tag</a>
700+
<span class="desc">tag a point in history as important</span>
701+
</h2>
702+
703+
<div class="block">
704+
705+
<p>
706+
If you get to a point that is important and you want to forever remember
707+
that specific commit snapshot, you can tag it with <code>git tag</code>.
708+
The <code>tag</code> command will basically put a permanent bookmark at
709+
a specific commit so you can use it to compare to other commits in the
710+
future. This is often done when you cut a release or ship something.
711+
</p>
712+
713+
<p>Let's say we want to release our Hello World project as version "1.0".
714+
We can tag the last commit (<code>HEAD</code>) as "v1.0" by running
715+
<code>git tag -a v1.0</code>. The <code>-a</code> means "make an annotated
716+
tag", which allows you to add a tag message to it, which is what you almost
717+
always want to do. Running this without the <code>-a</code> works too, but
718+
it doesn't record when it was tagged, who tagged it, or let you add a tag
719+
message. I would recommend always creating annotated tags.</p>
720+
721+
<pre>
722+
<b>$ git tag -a v1.0 </b>
723+
</pre>
724+
725+
<p>When you run the <code>git tag -a</code> command, Git will open your editor
726+
and have you write a tag message, just like you would write a commit
727+
message.</p>
728+
729+
<p>Now, notice when we run <code>git log --decorate</code>, we can see our
730+
tag there.</p>
731+
732+
<pre>
733+
<b>$ git log --oneline --decorate --graph</b>
734+
* 594f90b (HEAD, <span class="hl">tag: v1.0</span>, master) reverted to old class name
735+
* 8d585ea Merge branch 'fix_readme'
736+
|\
737+
| * 3ac015d (fix_readme) fixed readme title
738+
* | 3cbb6aa fixed readme title differently
739+
|/
740+
* 558151a Merge branch 'change_class'
741+
|\
742+
| * 3467b0a changed the class name
743+
* | b7ae93b added from ruby
744+
|/
745+
* 17f4acf first commit
746+
</pre>
747+
748+
<p>If we do more commits, the tag will stay right at that commit, so we have
749+
that specific snapshot tagged forever and can always compare future
750+
snapshots to it.</p>
751+
752+
<p>We don't have to tag the commit that we're on, however. If we forgot to
753+
tag a commit that we released, we can retroactively tag it by running the
754+
same command, but with the commit SHA at the end. For example, say we had
755+
released commit <code>558151a</code> (several commits back) but forgot to
756+
tag it at the time. We can just tag it now:</p>
757+
758+
<pre>
759+
<b>$ git tag -a v0.9 558151a</b>
760+
<b>$ git log --oneline --decorate --graph</b>
761+
* 594f90b (HEAD, tag: v1.0, master) reverted to old class name
762+
* 8d585ea Merge branch 'fix_readme'
763+
|\
764+
| * 3ac015d (fix_readme) fixed readme title
765+
* | 3cbb6aa fixed readme title differently
766+
|/
767+
* 558151a (<span class="hl">tag: v0.9</span>) Merge branch 'change_class'
768+
|\
769+
| * 3467b0a changed the class name
770+
* | b7ae93b added from ruby
771+
|/
772+
* 17f4acf first commit
773+
</pre>
774+
775+
</div>
776+
</div>
777+
693778
<p><a href="/remotes">On to Sharing and Updating Projects &#187;</a></p>
694779

0 commit comments

Comments
 (0)