How to mark important events / milestones in Git history?
Asked Answered
D

3

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?

Diffusion answered 21/1, 2014 at 13:13 Comment(0)
W
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.

Waves answered 21/1, 2014 at 13:16 Comment(1)
After talking to people and seeing this I realised you had the best answer.Diffusion
D
9

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

Durrace answered 21/1, 2014 at 13:20 Comment(3)
You probably want to include the -a option to create an annotated tag instead of a lightweight one.Ponce
But if you git checkout <tag> 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?Matthieu
Can I run 'git diff' against a tag to see changes since the tag?Ashby
W
4

I believe git tags are best suited for your purpose.

Ways answered 21/1, 2014 at 13:15 Comment(0)
W
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.

Waves answered 21/1, 2014 at 13:16 Comment(1)
After talking to people and seeing this I realised you had the best answer.Diffusion

© 2022 - 2024 — McMap. All rights reserved.