mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
Promotes a local topic branch to a remote tracking branch of the same name, by pushing and then setting up the git config. Thanks to ENTP: http://hoth.entp.com/2008/11/10/improving-my-git-workflow
13 lines
468 B
Bash
Executable file
13 lines
468 B
Bash
Executable file
#!/bin/sh
|
|
|
|
branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
|
|
|
|
remote_branch=$(git branch -r | grep "origin/${branch}")
|
|
test -z "${remote_branch}" && ( git push origin "${branch}" )
|
|
|
|
origin=$(git config --get "branch.${branch}.remote")
|
|
test -z "${origin}" && ( git config --add "branch.${branch}.remote" origin )
|
|
|
|
merge=$(git config --get "branch.${branch}.merge")
|
|
test -z "${merge}" && ( git config --add "branch.${branch}.merge" "refs/heads/${branch}" )
|