Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a simple command to convert a branch to a tag?
    text
    copied!<p>I am about to complete a tedious process of converting "dumb snapshots" to git. This process has been going very well (thanks to <a href="https://stackoverflow.com/questions/6628539/how-to-tell-git-that-its-the-same-directory-just-a-different-name/6629505#6629505">this rename process</a>), but now I realized that some of the branches that I created, do not merit a <code>branch</code> but rather a <code>tag</code>.</p> <p>Since everything is still local (never pushed to a repository), I found <a href="https://stackoverflow.com/questions/6357403/converting-git-branch-to-git-tag">this question</a> (and associated answer) somewhat more cumbersome than I prefer, so I was wondering whether I can take a shortcut via some simple "convert-from-branch-to-tag" command?</p> <p>Is there such a simple command to convert a branch to a tag?</p> <p>(I know I can just leave it as is, but I really like the way <code>gitk</code> highlights tags, helping me easily identify them).</p> <p><strong>UPDATE:</strong> Thanks to @Andy's answer below, I managed to come up with a shell script that does it all conveniently and painlessly. I am sharing this script for the benefit of all and as special thanks to this great community who made moving for CVS to git possible for me:</p> <pre><code>#!/bin/sh BRANCHNAME=$1 TAGNAME=$2 echo "Request to convert the branch ${BRANCHNAME} to a tag with the same name accepted." echo "Processing..." echo " " git show-ref --verify --quiet refs/heads/${BRANCHNAME} # $? == 0 means local branch with &lt;branch-name&gt; exists. if [ $? == 0 ]; then git checkout ${BRANCHNAME} git tag ${BRANCHNAME} git checkout master git branch ${BRANCHNAME} -d echo " " echo "Updated list branches, sorted chronologically: " echo "---------------------------------------------- " git log --no-walk --date-order --oneline --decorate $(git rev-list --branches --no-walk) | cut -d "(" -f 2 | cut -d ")" -f 1 else echo "Sorry. The branch ${BRANCHNAME} does NOT seem to exist. Exiting." fi </code></pre>
 

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