I’m not a developer. Maybe someday I will feel like I’ve graduated from person who writes code to a developer but I see what developers do and it blows me away. So this is my attempt to write out how I’ve started to use Git with Branches for the purposes of managing bugs and development features. This might feel like random thoughts and I’ll be honest, they are to some degree.
What I’m Trying To Do
So what am I trying to do in Visual Studio + Git (well in this case BitBucket)? I’m trying to have a place where I can have two parallel tracks of code. One that is for bug fixes and the other is to allow me to complete larger “feature” requests. As major features are completed, I would want the tracks to merge with each other and then we would start the process again. I even made a Visio of what I was trying to do.
So I’ve been using BitBucket + Jira for about two years to keep track of projects, features, etc. and I figured now was the time to figure out how to do the above. If you haven’t used Git or BitBucket to save your projects you really should. If you write code and it’s not in a shared repository you should change and maybe I’ll blog about that some time. Moving a project to a Git but I’m sure there are lots of those out there.
Solution
If you have never used Git/BitBucket there is a concept called a branch. We branch our code to allow us to work in parallel on several items and then at the end we merge everything together. The reason this is important is I might be working on amazing feature A but it’s half-way done and suddenly high-impact bug B might be discovered. If I’m just working on the code in a single place then I need to either take steps to hide feature A or rush it to completely so I can get the build out.
So we start by creating two branches. I’m going to call it BugFix and FeatureName.
All a branch does is creates a symbolic link between the master and changes that would go into the branch. So once I’ve created my two branches I can go to Visual Studio and do a fetch to retrieve back those branches. NOTE: This assumes you have already committed to the master and have setup that part. Please make sure you commit first.
So after our fetch of the master when we look under branches now we see this:
From here, I can right-click on each branch and choose to “Checkout”. When I do that, the code of Visual Studio changes from the existing branch to the other. Essentially, I can now flip between the two worlds as I need to. I can do some work on a bug, flip back to my feature request. It’s pretty darn neat. If we look at the commits we can see two very different paths now.
Once we have completed that sprint of bugs fixes and the feature is complete, we can merge everything back to the master. So from BitBucket I can choose a new Pull Request to merge BugFix04 to master. The important thing is I want to close this branch so I can get the master completely cleaned up and ready to branch again.
Once I’ve closed and merge the bug fix branch, I would do the same with my feature request branch. Once both are merged, we would want to go back and make sure we didn’t create any new bug via regression. But if everything looks good in the master I could branch again and repeat the process over. It’s pretty neat.
Again, I’m not a developer and I’m sure I could do something easier, faster, better in the above. If any real programmers happen to read this please feel free to share.
1 COMMENTS