Skip to content

Instantly share code, notes, and snippets.

@tonatiuh
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonatiuh/612edc89b3bb20ef74bf to your computer and use it in GitHub Desktop.
Save tonatiuh/612edc89b3bb20ef74bf to your computer and use it in GitHub Desktop.
Bash functions that make automate some day to day tasks

Function that automates the creation of a new gitflow branch:

#!/bin/bash

function git_start_feature() {
  story_title=$1
  story_title=${story_title,,} # downcase string
  story_title=${story_title// /-} # replace spaces by dashes
  story_title=${story_title//\//-} # replace slashes by dashes
  story_title=${story_title//[.,:]/} # remove punctuation characters

  git checkout -b feature/$story_title
}

Being on the develop branch, you can just say

$ git_start_feature "this is my new nice feature: that I'm working on with slashes/and .dots"

and a new branch will be created starting from develop, as:

feature/this-is-my-new-nice-feature-that-im-working-on-with-slashes-and-dots
@TheNaoX
Copy link

TheNaoX commented May 7, 2014

Well not, it's a lightweight version of it

@tonatiuh
Copy link
Author

tonatiuh commented May 7, 2014

Yeah, it's lighter @TheNaoX.

@daniel-g pretty nice! I like it, so trick there is to prefix the name of the file that contains the script with "git-", and load it in the bash session.

Also they can be taken into account by git by encapsulating the script in a code function name with the prefix "git", I found doc talking about that here: https://coderwall.com/p/wjuoag

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