DEV Community

Cover image for Using Git Tags To Version Coding Tutorials

Using Git Tags To Version Coding Tutorials

Emma Bostian ✨ on March 16, 2019

Coding tutorials can be difficult to structure. It’s often so easy to get caught up in your expanding code base and keep track of important project...
Collapse
 
juliang profile image
Julian Garamendy

Thanks for this! I didn't know the difference between lightweight and annotated tags.

I also use tags when trying to identify when a bug was introduced. I normally create "before-x", "after-x" tags to quickly jump between commits without accidentally checking out the wrong thing (which would add even more confusion)

Collapse
 
xexyl profile image
xexzy

For debugging you should really look into git bisect.

Maybe it’s not a good way for you but it’s specially useful and iirc designed for debugging/finding which commit introduced the bugs you’re looking for.

Collapse
 
juliang profile image
Julian Garamendy

Awesome! Thanks! I didn't know about git bisect either!

Thread Thread
 
xexyl profile image
xexzy

No problem mate!

I have seen some really interesting articles on it but I am not sure where exactly. I think I could find it if I were to bother but I have actually never used it as I have always used my own system. Even so it’s good to have alternative methods for things and if nothing else it’s something new to learn and by extension come up with new ideas and so on.

It should be remembered too that you can use it for more than just finding a commit a bug was introduced. In the end binary searching is a valuable tool and you can use similar systems for making decisions irl by taking a list of things and breaking them into the keep pile until you finally have two left.

Anyway glad to have offered something useful!

Cheers.

Collapse
 
andychiare profile image
Andrea Chiarelli

...or use Git Tutor

Collapse
 
jfn0 profile image
jfn0

Didnt know a bout git tutor, thank!

Collapse
 
jankeromnes profile image
Jan Keromnes

That's really smart! Many thanks for this helpful write-up.

We also tried to address this with gitpod.io snapshots, which allow you to capture and share the full state of a workspace with a URL (see ssloy's awesome 3D tutorials using snapshots for each step: github.com/ssloy/tinyraycaster/wik... ).

But today I learned that you can also do it with tags. Thanks again!

Collapse
 
seankilleen profile image
Sean Killeen

Thanks for the article!

I've been going back and forth on my approach and I wonder if you have a preference.

Would you prefer:

  • Making these commits along the master branch and tagging? In this case, when folks first pull the repository, they'll be looking at the final version.
  • Making these commits in branches off of each other (e.g. step-02 is tagged to the latest in a branch that is created off of step-01 which was created off of step-00). This seems like it could be more complex to maintain, but results in those taking the tutorial pulling down the "before" version at first.

Not sure which way to go, and wasn't sure if you or other readers here might have some preferences.

Thanks again!

Collapse
 
learnbyexample profile image
Sundeep

very nicely presented and explained, am gonna try on my repos

one question, is it possible to add tags to a particular commit in history?

Collapse
 
emmabostian profile image
Emma Bostian ✨

I'm not sure, you'd have to check the official documentation :)

Collapse
 
xexyl profile image
xexzy

Yes. Yes you can. See the following for example :

stackoverflow.com/questions/440417...

Collapse
 
learnbyexample profile image
Sundeep

cool, thanks for the link, exactly what I was looking for :)

Thread Thread
 
xexyl profile image
xexzy

Welcome mate!

Collapse
 
mikeborn profile image
Michael Born

Pretty cool! I've been writing some CF tutorials recently, and I briefly wondered "Hmm, would Git tagging make this way easier to switch between examples?" Because otherwise you either give the student/reader the Full Working Code, or nothing at all.

Thank you! I'll give tags another shot.

Collapse
 
geefygeorge profile image
David Salter

Great article and fantastic technique to help others learn. :)

Collapse
 
lokidev profile image
LokiDev

As always: Very useful. I knew about tags and used it very poorly. This article gave more insight (I didn't knew the difference between lightweight and annotated tags before)

Collapse
 
xrr2016 profile image
ColdStoneBoy

good article!

Collapse
 
thomascraig profile image
Thomas Craig

Great post as we are currently going thru this exercise for a current project and this is helpful.

Collapse
 
gidrek profile image
Giovanni Cortés

I am doing a monogame tutorial and I using branches instead. Is very useful

Collapse
 
jsjoeio profile image
Joe Previte (he/him)

Genius idea! Thank you for sharing!

Collapse
 
emmabostian profile image
Emma Bostian ✨

Aw thanks Joe!

Collapse
 
wiltel492019 profile image
Wiltel492019

Milestones great.

Collapse
 
jnario profile image
Jose Nario

Not sure why I always neglect tags, but clearly I'm missing out. Thanks for the inspiration.