How to mark important events / milestones in Git history?

5.4k views Asked by At

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?

3

There are 3 answers

1
tomkr On BEST ANSWER

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.

0
gravetii On

I believe git tags are best suited for your purpose.

3
First Zero On

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