Skip to content

Instantly share code, notes, and snippets.

@kitsuyui
Created November 12, 2015 14:21
Show Gist options
  • Save kitsuyui/78d09cb6e4447a111b32 to your computer and use it in GitHub Desktop.
Save kitsuyui/78d09cb6e4447a111b32 to your computer and use it in GitHub Desktop.
今のワーキングディレクトリに影響を及ぼさずに staged と unstaged の内容を commit した branch をそれぞれ作る。 ref: http://qiita.com/kitsuyui/items/11dcad2c4fe386de2727
#!/usr/bin/env bash
set -eu
current_branch=$(git rev-parse --abbrev-ref HEAD)
date=$(date +%Y%m%d-%H%M%S)
wip1="wip/$date/staged"
wip2="wip/$date/unstaged"
message_wip1="Autosave Staged files $date"
message_wip2="Autosave Unstaged files $date"
{
set +e
git checkout -q -B "$wip1"
git commit -q -m "$message_wip1" > /dev/null 2>&1
git checkout -q -B "$wip2"
git add .
git commit -q -m "$message_wip2" > /dev/null 2>&1
}
git symbolic-ref HEAD "refs/heads/$wip1"
git reset -q
git symbolic-ref HEAD "refs/heads/$current_branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment