Git push new local branch to remote, without having to specify name -
when working on patch fixes specific, tracked issue, our workflow looks like:
1. git checkout patch; git pull upstream patch; # make sure we're up-to-date 2. git checkout -b issue-435-db-integrity-exception 3. # code awesome 4. git commit -am "fixes issue #435" 5. git push -u origin issue-435-db-integrity-exception
then open pull request origin/435
upstream/patch
, code review can take place on github/bitbucket. start on step #1.
but, though may sound bit whiny, great if didn't have explicitly name remote branch want create:
git push -u origin issue-435-db-integrity-exception
it's not lot of fun type branch name on again, , disagree changing 435
or more compact.
is there way (1) force git push current branch named branch, creating if necessary without explicitly naming it? not globally, on-the-spot kind of flag.
or, possible (2) access current branch in git alias, , write like:
[alias] pnew = push -u origin $(git symbolic-ref --short head)
(but doesn't work - thinks --short
option meant push
)
you use following:
# git 1.8.5+ git push origin -u @ # older versions of git git push origin -u head
by using @
or head
, git push checked-out branch origin
, , if branch doesn't exist on origin
yet, create it.
so, in example, if have issue-435-db-integrity-exception
checked out, git push origin @
make new branch same name on origin
.
Comments
Post a Comment