man-pages/man1/git-symbolic-ref.1.html
2021-03-31 01:06:50 +01:00

120 lines
3.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GIT-SYMBOLIC-REF</TITLE>
</HEAD><BODY>
<H1>GIT-SYMBOLIC-REF</H1>
Section: Git Manual (1)<BR>Updated: 03/04/2021<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
git-symbolic-ref - Read, modify and delete symbolic refs
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<PRE>
<I>git symbolic-ref</I> [-m &lt;reason&gt;] &lt;name&gt; &lt;ref&gt;
<I>git symbolic-ref</I> [-q] [--short] &lt;name&gt;
<I>git symbolic-ref</I> --delete [-q] &lt;name&gt;
</PRE>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
Given one argument, reads which branch head the given symbolic ref refers to and outputs its path, relative to the <B>.git/</B> directory. Typically you would give <B>HEAD</B> as the &lt;name&gt; argument to see which branch your working tree is on.
<P>
Given two arguments, creates or updates a symbolic ref &lt;name&gt; to point at the given branch &lt;ref&gt;.
<P>
Given <B>--delete</B> and an additional argument, deletes the given symbolic ref.
<P>
A symbolic ref is a regular file that stores a string that begins with <B>ref: refs/</B>. For example, your <B>.git/HEAD</B> is a regular file whose contents is <B>ref: refs/heads/master</B>.
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<P>
-d, --delete
<DL COMPACT><DT id="1"><DD>
Delete the symbolic ref &lt;name&gt;.
</DL>
<P>
-q, --quiet
<DL COMPACT><DT id="2"><DD>
Do not issue an error message if the &lt;name&gt; is not a symbolic ref but a detached HEAD; instead exit with non-zero status silently.
</DL>
<P>
--short
<DL COMPACT><DT id="3"><DD>
When showing the value of &lt;name&gt; as a symbolic ref, try to shorten the value, e.g. from
<B>refs/heads/master</B>
to
<B>master</B>.
</DL>
<P>
-m
<DL COMPACT><DT id="4"><DD>
Update the reflog for &lt;name&gt; with &lt;reason&gt;. This is valid only when creating or updating a symbolic ref.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
<P>
In the past, <B>.git/HEAD</B> was a symbolic link pointing at <B>refs/heads/master</B>. When we wanted to switch to another branch, we did <B>ln -sf refs/heads/newbranch .git/HEAD</B>, and when we wanted to find out which branch we are on, we did <B>readlink .git/HEAD</B>. But symbolic links are not entirely portable, so they are now deprecated and symbolic refs (as described above) are used by default.
<P>
<I>git symbolic-ref</I> will exit with status 0 if the contents of the symbolic ref were printed correctly, with status 1 if the requested name is not a symbolic ref, or 128 if another error occurs.
<A NAME="lbAG">&nbsp;</A>
<H2>GIT</H2>
<P>
Part of the <B><A HREF="/cgi-bin/man/man2html?1+git">git</A></B>(1) suite
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="9"><A HREF="#lbAF">NOTES</A><DD>
<DT id="10"><A HREF="#lbAG">GIT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:15 GMT, March 31, 2021
</BODY>
</HTML>