Monday, June 8, 2020

git svn

"Cherry pick" all changes required to make same as another branch:

git merge --squash -X theirs <other_branch>

Makes no commit, but stages all changes

Monday, February 3, 2020

Git project branch and directory info

To get the Git top level, or root, of the repo:

git rev-parse --show-toplevel

Get the current current branch name:

git rev-parse --abbrev-ref HEAD

Get the current working directory relative to project root:

echo "${PWD##$(git rev-parse --show-toplevel)}"

Get the current working directory relative to project root and the branch name in one line:

echo "${PWD##$(git rev-parse --show-toplevel)} [$(git rev-parse --abbrev-ref HEAD)]"