Hacker News new | ask | show | jobs
by victorbello 3755 days ago
I use feature branched for everything, usually named after an issue number. I created a script that allows me to commit whenever I get a task done, not the whole feature, and that script takes care of adding the files, committing them with a message, tags it with the issue number (current branch name), and pushes to remote. That way, every time I save, the changes are saved on the remote GIT repo in case my computer dies or something.

Here's the code in case you wanted to use it:

savework()

{

  if git diff --exit-code --quiet

  then

    echo "There are no changes to save, NONE!";

  else

    echo "Stage everything for commit -------------";

    addit; # an alias for "git add -A ."

    echo "Commit all changes with message $@ --------------";

    commit "$@"; #commit is an alias for "git commit -m"

    echo "Push branch to remote --------------"
    psh; # an alias for git push origin $(git branch | grep "*" | sed "s/* //")

  fi
}

Use it like this: savework "COMMIT MESSAGE HERE"

2 comments

Thank you, I'm going to modify it to:

saveallwork "commit message" --ignore "somedir/skipme.too"

I usually have just 1 or 2 files I don't want to include in a commit, but thank you again, it will definitely shave a few mins here and there.

That seems like it could generate an excessive amount of commits (or maybe not everyone saves hundreds of times per day).

Just curious -- do you squash commits when merging one of these feature branches?