Member-only story

3 Common Git Scenarios and How to Deal With Them

Renaming branches, overwriting Git history, and creating feature branches

billydharmawan
Better Programming
6 min readNov 18, 2020

--

USB stick connected to a laptop
Photo by Brina Blum on Unsplash.

As developers, most of us spend a fair amount of time on Git to manage our version control. We also use Git to collaborate with other developers to track bug fixes, build new features, refactor codes, and many more things.

In this tutorial, I am going to share with you three common scenarios that you will face or have encountered previously and how to deal with them.

Rename Existing Branch

I don’t know about you, but where I work, I do my development based on Jira tickets. What this means is all my pull requests will have their corresponding branches named as per the respective ticket number. This is also true for the first commit of the pull request (i.e. it starts with the ticket number followed by the commit message). All this is because Jira has a nice GitHub integration that links all the pull requests to the ticket.

So, this is the first scenario I want to discuss:

  • You have started working on a ticket.
  • You have created a pull request and named the branch as per the ticket number.
  • You find out that you had a typo in the ticket number or the…

--

--

billydharmawan
billydharmawan

Written by billydharmawan

An ordinary man trying to leave a good legacy on earth

No responses yet