Project

General

Profile

Git use

This is a place to put your own notes on how to use git commands in a convenient way.

Tagging

Git can create signed tags, meaning tags signed with a GPG key. I don't have the GPG software on my laptop, so for now I'm using unsigned tags.

One can tag any type of object. I think we'd be best off tagging only commits. If one does "git show HEAD", you will see that the output begins with "commit" (followed by the SHA1). To tag the your local branch, says just after a commit, you can do:

   git tag some_tag

In this case an unsigned, lightweight (non-annotated) tag will be created and associated with the SHA1 of HEAD.

If you want a message associated with your tag (annotated, not lightweight), then you can use either:

   git tag -a some_tag

In which case an editor will pop up. Or:
   git tag -m'some message' some_tag

After tagging, if you want your tag to be pushed up along with your other changes, a separate push for the tags is necessary:

   git push --tags

So, you will usually do something like:

   git tag -m'some message' v0.0
   git push
   git push --tags

Then when someone pulls (after the push of the tags), they will get the tag also; there is no special option to pull the tags.

To tag an object that is not associated with the last commit, you need to know its SHA1. To find the SHA1 of the head of your repository, use git show HEAD; the first line printed, starting with the word commit, contains the SHA1 for the commit that is the HEAD of your repository. Here's an example:

thomas:fast paterno$ git show HEAD
commit b3e918a41124a8996336555ec98c95a941a21a41
Author: Marc Paterno <paterno@fnal.gov>
Date:   Mon Nov 23 22:58:19 2009 -0600

    Another attempt at portable printing for pthread_t

diff --git a/SimpleProfiler/SimpleProfiler.cc b/SimpleProfiler/SimpleProfiler.cc
index 11cab10..ff5db9c 100644
--- a/SimpleProfiler/SimpleProfiler.cc
+++ b/SimpleProfiler/SimpleProfiler.cc
@@ -451,12 +451,14 @@ void SimpleProfiler::start()
     // supported platforms.

     if (installed_) {
-      printf("Warning: second thread %lu required the profiler timer and\n" 
-             "another thread %lu has already started it.\n" 
-             "Only one thread can do profiling at a time.\n" 
-             "This second thread will not be profiled.\n",
-             reinterpret_cast<unsigned long>(pthread_self()),
-             reinterpret_cast<unsigned long>(owner_));
+      std::ostringstream os;
+      os << "Warning: second thread " << pthread_self()
+        << " required the profiler timer and\n" 
+        << "another thread " << pthread_self()
+        << " has already started it.\n" 
+        << "Only one thread can do profiling at a time.\n" 
+        << "This second thread will not be profiled.\n";
+      printf("%s", os.str().c_str());
       return;
     }

The first line says this object is of type commit, and has SHA1 b3e918... (usually the first handful of hex digits suffices for commands). The rest is how git shows a commit object.

To tag the HEAD of this repository (actually, to tag this commit object, regardless of whether or not it is still the HEAD --- this tag could be done at any time), use the following:

    git tag -a testing-01 b3e918a41124a8996336555ec98c95a941a21a41

Here -a tells git to make an unsigned, annotated tag object, testing-01 is the name of the tag, and we've specified the SHA1 of the object we want to tag. This command will start up an editor, to allow you to enter a description of this tag. Make the description of the format:

    One introductory line.

    After a blank line, put as many paragraphs as you need to explain the purpose of this tag;
    this might be zero paragraphs.