Page MenuHomePhabricator
Paste P3314

git-attach-head
ActivePublic

Authored by mmodell on Jun 29 2016, 4:28 PM.
Tags
None
Referenced Files
F4213117: git-attach-head
Jun 29 2016, 4:28 PM
Subscribers
#!/bin/bash
branch=$(git branch -r --no-color --contains HEAD | head -n1 | awk '{gsub(".*/","");print $1}')
commit=`git rev-parse HEAD`
branch_commit=$(git rev-parse "$branch")
echo "branch: $branch HEAD=$commit branch_commit=$branch_commit"
if [ "$commit" == "$branch_commit" ]; then
echo git checkout $branch
fi