Skip to content

Instantly share code, notes, and snippets.

@nadeem-khan
Last active June 22, 2022 04:41
Show Gist options
  • Save nadeem-khan/b2739c5be0028d3d1b70 to your computer and use it in GitHub Desktop.
Save nadeem-khan/b2739c5be0028d3d1b70 to your computer and use it in GitHub Desktop.
Git Tagging and Branching 101

Git Tagging and Branching 101

Here are the best practices for using Git Branches and Git Tags:

Git Tags

A ref pointing to a tag or commit object. To put simply, a tag is a way to mark a point in time in your repository. Here are some things that you should keep in mind when working with tags:

-You should add a tag to mark a released version. If you then need to make bug fixes to that release you would create a branch at the tag

-In contrast to a head, a tag is not changed by a commit

-If you checkout a tag, you will need to create a branch to start working from it

Git Branches

Best practice is branch out, merge often and keep always in sync. There are pretty clear conventions about keeping your code in a separate branches from master branch and here are some things that you should keep in mind when working with branches:

-You are about to make an implementation of major or disruptive change

-You are about to make some changes that might not be used

-You want to experiment on something that you are not sure it will work

-When you are told to branch out, others might have something they need to do in master

-If you checkout a branch, you will directly see the latest commit ('HEAD') of that branch

Rule of thumb is after branching out, you should keep in sync with the master branch. Because eventually you need to merge it back to master. In order to avoid a huge complicated mess of conflicts when merging back, you should commit often, merge often.

How to use them together (the usual case)

When to use Git branch and tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment