5

I have a repo consisting of files, related to four Ruby homework task. My fifth task is to refactor each of the previous four tasks the best way I can and mark each small refactoring as a single git commit, so that when one opens the git history, they could easily see what has changed (like Use map instead of each, Rename instance variable, etc.). I have a branch, called task-1 and now I am done with my commits for the first task. I want to merge it to master. Then I will make a new branch task-2 and when ready, will merge it to master. But I want to have a clear indicator where commits, related to task 1 finish and commits for task 2 begin in git history. One way would be to amend the commit message of my last commit to include ..and finish task 1, but I was wondering if there is some more intelligent way. Another way I though of, was to make a minor change, like add a space somewhere and use the commit message for this commit. What is the proper way to mark important events / milestones in git / Github?

Alexander
  • 17,699
  • 19
  • 72
  • 107

3 Answers3

8

Use git tag to mark important milestones in your code.

Example - git tag -a v1 will tag the current code as v1. You can always checkout this code by running git checkout v1

git tag -l can list all your tags.

Finally, remember to push your tags to the remote repository - git push --tags

First Zero
  • 18,964
  • 6
  • 42
  • 44
  • 3
    You probably want to include the `-a` option to create an annotated tag instead of a lightweight one. – Chris Jan 21 '14 at 13:28
  • But if you `git checkout ` later on, you end up with a `Detached HEAD`. Is there a way of simply assigning a name to a particular commit (like an alias to the hash a commit generates) with no strings attached? – gone Oct 18 '16 at 11:51
4

I believe git tags are best suited for your purpose.

gravetii
  • 7,728
  • 6
  • 41
  • 67
3

Tagging is probably something you want to do, but if you want something in your commit log, the following may work:

You could use the no fast-forward tag when merging your branch. This adds a specific commit for the merging, and you could add 'finish task 1' to the commit message. So for instance you would do:

git merge task-1 --no-ff

And then you have a clear indication of where this branch was merged in.

I hope I understood your question properly, and this helps you out.

tomkr
  • 56
  • 6
  • After talking to people and seeing [this](http://stackoverflow.com/questions/9069061/what-is-the-difference-between-git-merge-and-git-merge-no-ff) I realised you had the best answer. – Alexander Jan 22 '14 at 07:45