How do you stay in the right git branch?

I use git but I am constantly finding myself in the wrong branch and then when I commit I realize I have done a ton of work in the wrong place.

How do you avoid doing this? Is it just something that comes with time? Or is there some trick you have to avoid this?

Replay

i dont use this (see my comment) but i know these things exist: https://github.com/jimeh/git-aware-prompt

i.e: a bash prompt which changes as you change branches to keep you aware of which branch you're on.

A very simple solution, but it works very well. Post-its! Yes, add a post-it somewhere you'll glance over while coding. "Have you checked your git branch?" A more technical solution would be to make it show when opening a terminal or your IDE, maybe change the 'default' file to something that asked you to check. Or use a post-it program. Or, if you're going for a more fun solution, add a speech synthesis program to your login script that says that. There are some code editors/IDE's that integrate with git and show the branch in a status bar.

You can use git branch in prompt like this but this could be only applied, when you are using bash, or you can use Oh My Zsh with git plugin.

Another option could be a pre-commit hook, which runs only once: you can find here an example. This could warn you about the target branch. Pre-commit hooks can also protect the master/production branch, no push without pull-request. With Yelp's framework, you have more options.

Category: git Time: 2016-07-29 Views: 0
Tags: git

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.100 (s). 12 q(s)